Keeping object in cache regardless of max-age

Blake Crosby blake.crosby at cbc.ca
Wed Apr 10 16:53:15 CEST 2013


The problem is not the cache time. but the fact that Varnish immediately 
purges the object from cache after the TTL has expired.

This means that regardless if the object has changed or not, another 
request must be made to the backend to get a new copy. Instead of just 
marking the object as invalidated and using an if-modified-since 
(conditional GET) to see if it should update the cache copy or not.

Blake

On 10/04/2013 10:36, Mad Indian wrote:
> unless I'm misunderstanding in the vcl_fetch section you should be able
> to for instance if ttl is less and 2 mins make it 2 mins
>
> if (beresp.ttl < 120s) {
> set beresp.ttl = 120s;
> }
>
> or if you want to say cache any url that contains members in it for  3h
>
> if (req.url ~ "(/members/)") {
> set beresp.ttl = 3h;
> }
>
>
> ------------------------------------------------------------------------
> *From:* Blake Crosby <blake.crosby at cbc.ca>
> *To:* varnish-misc at varnish-cache.org
> *Sent:* Wednesday, April 10, 2013 9:02 AM
> *Subject:* Re: Keeping object in cache regardless of max-age
>
> Anders,
>
> Thanks for the link. This helps.
>
> I'm going to put my vote in for this to be at least discussed at next
> months User Group meeting. I just took a look through the list archives,
> and it seems like I'm not the only one looking for this functionality :)
>
> Blake
>
>
> On 10/04/2013 02:41, Anders Daljord Morken wrote:
>  > On Wed, Apr 10, 2013 at 1:15 AM, Blake Crosby <blake.crosby at cbc.ca
> <mailto:blake.crosby at cbc.ca>
>  > <mailto:blake.crosby at cbc.ca <mailto:blake.crosby at cbc.ca>>> wrote:
>  >
>  >    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?
>  >
>  >
>  > Possible, well, sort of. Some work has been made on this, but it hasn't
>  > been merged into mainline, let alone released.
>  > See
>  > https://www.varnish-cache.org/trac/wiki/BackendConditionalRequests for
>  > more information. The Varnish devs may have more information, but I
>  > don't think we can expect a timeline commitment yet.
>  >
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org <mailto:varnish-misc at varnish-cache.org>
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
>



More information about the varnish-misc mailing list