Caching only images, no cookies
Per Buer
perbu at varnish-software.com
Wed Feb 2 10:49:02 CET 2011
David,
On Wed, Feb 2, 2011 at 10:14 AM, David Murphy <david at firechaser.com> wrote:
> Morning Per
>
> So the default behaviour of Varnish (only extended if I start writing
> my own .vcl) would make a smart choice about what should be cached?
> That sounds good. So provided that I strip the cookies for the image
> file types, then Varnish will spot that these request do not have any
> cookies and will safely cache them, ignoring all other requests (since
> I've not stripped their cookies).
Right.
> Something as simple as
>
> sub vcl_recv {
> if (req.url ~ "\.(png|gif|jpg)$") {
> remove req.http.Cookie;
> }
> }
Right. Provided your backend produces sane cache-control headers. If
there is no information on how long to cache it Varnish will cache for
a default period of 120 seconds. You can override the TTL -
http://www.varnish-cache.org/docs/trunk/tutorial/increasing_your_hitrate.html#overriding-the-time-to-live-ttl
> ...and nothing else in .vcl file?
No. That should be sufficient.
--
Per Buer, Varnish Software
Phone: +47 21 98 92 61 / Mobile: +47 958 39 117 / Skype: per.buer
Varnish makes websites fly!
Want to learn more about Varnish? http://www.varnish-software.com/whitepapers
More information about the varnish-misc
mailing list