Can varnish cache files without specific extension or residing in specific directory
Posted
by
pataroulis
on Server Fault
See other posts from Server Fault
or by pataroulis
Published on 2012-08-03T10:27:07Z
Indexed on
2012/09/01
15:39 UTC
Read the original article
Hit count: 231
I have a varnish installation to cache (MANY) images that my service serves. It is about 200 images of around 4k per second and varnish happily serves them according to the following rule:
if (req.request == "GET" && req.url ~ "\.(css|gif|jpg|jpeg|bmp|png|ico|img|tga|wmf)$") {
remove req.http.cookie;
return(lookup);
}
Now, the thing is that I recently added another service on the same server that creates thumbnails to serve but it does not add a specific extension. The files are of the following filename pattern:
http://www.example.com/thumbnails/date-of-thumbnail/xxxxxxxxx.xx
where xx are numbers, so xxxxxxxxx.xx could be 6482364283.73 (two numbers at the end) (actually this is the timestamp so I can keep extra info in the filename)
That has the side effect that varnish does not cache them and I see them constantly being served by apache itself.
Even though I can change the format from now on to create thumbs ending in .jpg
, is there a way to change the vcl file of my varnish daemon to either cache everything under a directory (the thumbnails
directory) or everything with two numbers at its extension?
Let me know if I can provide any additional info !
Thanks!
© Server Fault or respective owner