Keeping object in cache regardless of max-age
Blake Crosby
blake.crosby at cbc.ca
Wed Apr 10 01:15:05 CEST 2013
Hello,
I'm noticing the following behavior with Varnish.
When an object is fetched from the Origin with a TTL of 30 seconds
(Cache-Control: max-age=30) the object is immediately flushed from the
cache once the 30 second time elapses.
This results in Varnish having to issue a "full" HTTP GET to the
origin for the object (even if it hasn't changed) when time > 30
seconds.
Is it possible for Varnish to keep the object in cache past its TTL
and if a future request is made for that object (which is now expired)
that varnish will issue a If-Modified-Since (IMS) request. If the
origin returns a 304 Not-Modified Varnish will serve the object from
cache and reset the TTL counter?
For Example:
00:00:00 GET /index.html (TTL 30 seconds)
00:00:30 object expired, but remains in cache
00:00:45 GET /index.html, varnish makes a IMS request to origin.
Origin returns 304
00:01:15 object expired, but remains in cache
,,,
The LRU rules will still apply for purging objects as the cache fills.
This, by the way, is how the caching works with Akamai (which we are
currently using). Our origin is specifically tuned to handle a lot of
IMS requests (and thus 304s). However when fronting the origin with
Varnish, the majority of the requests were 200s as the objects in the
cache always expired in 30 seconds.
If you need any specific details (VCLs, etc..) let me know. Thanks in advance.
--
Blake Crosby <blake.crosby at cbc.ca>
Team Lead / Chef D'équipe
Media Production Support / Soutien à la production des médias
Canadian Broadcasting Corporation / Societé Radio-Canada
Office/Bureau: 9B122-K * Tel.: (416) 205-3103 * DID: 1-151-3103
More information about the varnish-misc
mailing list