cache files pass php

Darryl Dixon - Winterhouse Consulting darryl.dixon at
Fri Jun 27 03:34:24 CEST 2008

> Is there an easy vcl trick to get varnish to always pass php requests to
> the
> webserver and to cache images, css javascript, etc?
> I would like
> apache->varnish->client
> If the client requests a document, the php is run on the webserver,
> varnish
> takes it and downloads it to the client so that the apache thread can be
> used for other things. Varnish can cache the images and text files as they
> don't change.
> Thoughts?

Hi Jack,

This seems straightforward, in vcl_recv you would need something like:
sub vcl_recv {
if (req.url ~

The idea is that items that you 'know' are cacheable get looked up in the
cache and fetched from the backend if necessary, and that everything else
otherwise gets passed straight to the backend for servicing.

(note that this is an extremely abbreviated example that probably omits
several important considerations like cookies, etc. Including, depending
on what headers, etc the backend emits, you may want some more code in
vcl_fetch to decide whether something is insert-ed into the cache or
pass-ed onwards)

Hope this helps,

Darryl Dixon
Winterhouse Consulting Ltd

More information about the varnish-misc mailing list