VCL config file for specific URLs

Rob S rtshilston at gmail.com
Sat Jan 9 11:25:59 CET 2010


pub crawler wrote:
> That works fine, but we want Varnish to only do this on certain pages.
>
> More simply and shorter in number we want Varnish to adhere to the
> cookies only on certain user customizeable pages.
>
> For example (cache these in Varnish):
> http://www.website.com/Template/index.cfm
> http://www.website.com/Template/Review.cfm/flat/ID=xxxx
>
> DO NOTE CACHE THESE - pipe to backend:
> http://www.website.com/Template/dsp_addreview.cfm
> http://www.website.com/Template/mapinput.cfm
>
> Any ideas on how to best go about providing a list of URLs to pipe in
> our default.vcl file?
>   
I'm not sure of the best way to supply a large list of URLs to pipe, but 
I'd suggest that you think about turning the logic around.  I don't know 
the nature of your site, but presumably it's safe to cache all JPEGs and 
similar.  How much load would be alleviated by caching everything whose 
content type is not text/html?

Then, for text/html, is it possible for you to edit your backend site 
and add a header such as "X-Is-Cacheable: yes" in your index.cfm and 
Review.cfm?  Then, in vcl_fetch, you'd do something like:

if content-type = text/html
    if X-Is-Cacheable = yes
        cache this
    else
        don't cache
    end if
else
    cache this
end if


You might find this approach simpler than writing a big long list of 
pages not to cache.


Rob



More information about the varnish-misc mailing list