Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Misc

Using varnish to increase the cache time of slow pages

 

 

Varnish misc RSS feed   Index | Next | Previous | View Threaded


TFigueiro at au

Mar 9, 2012, 2:33 PM

Post #1 of 3 (557 views)
Permalink
Using varnish to increase the cache time of slow pages

I wrote a blog post describing quick-win modification I made to our Varnish configuration last week. It lets us keep the default page cache-time low so content is fresh but specifically increases the TTL for pages which are slow to generate.

The code is for Varnish 2.1.5 but I'm sure it can be easily adapted to 3.x so I thought I'd share it with the list.

http://microrants.blogspot.com.au/2012/03/using-varnish-to-increase-cache-time-of.html


Cheers.
Thiago.

______________________________________________________
CONFIDENTIALITY NOTICE
This electronic mail message, including any and/or all attachments, is for the sole use of the intended recipient(s), and may contain confidential and/or privileged information, pertaining to business conducted under the direction and supervision of the sending organization. All electronic mail messages, which may have been established as expressed views and/or opinions (stated either within the electronic mail message or any of its attachments), are left to the sole responsibility of that of the sender, and are not necessarily attributed to the sending organization. Unauthorized interception, review, use, disclosure or distribution of any such information contained within this electronic mail message and/or its attachment(s), is (are) strictly prohibited. If you are not the intended recipient, please contact the sender by replying to this electronic mail message, along with the destruction all copies of the original electronic mail message (along with any attachments).
______________________________________________________

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


contact at jpluscplusm

Mar 11, 2012, 3:13 PM

Post #2 of 3 (538 views)
Permalink
Re: Using varnish to increase the cache time of slow pages [In reply to]

On 9 March 2012 22:33, Thiago Figueiro <TFigueiro [at] au> wrote:
> I wrote a blog post describing quick-win modification I made to our Varnish configuration last week.  It lets us keep the default page cache-time low so content is fresh but specifically increases the TTL for pages which are slow to generate.
>
> The code is for Varnish 2.1.5 but I'm sure it can be easily adapted to 3.x so I thought I'd share it with the list.
>
> http://microrants.blogspot.com.au/2012/03/using-varnish-to-increase-cache-time-of.html

Thanks for posting this. I like the idea of tuning a TTL coarsely
based on the time it took you to generate that resource.

However, I have a couple of quibbles with this *implementation*:

1) Every bit of logic you embed into VCL is something you have to work
at if you move to another HTTP cache. The wonderful thing about HTTP
is it's a *standard* - and it includes its own method(s) for
communicating the TTL of a particular resource. By embedding this
logic in Varnish, you make it so that any other cache you try to use
later either has to support the same capabilities as Varnish, or makes
you do what I'm about to suggest: make the *back-end* decide how long
the resource can be cached.

By doing *that* (i.e. making the origin server output
standards-compliant caching headers, possibly based on how long it
took to produce the content) you not only enable Varnish to do The
Right Thing, but *every* HTTP-speaking cache/proxy/etc you might use
down the line.

Basically (and I totally accept this is a bigger challenge than just
munging the TTL in VCL!), fixing your back-end's code so it outputs
the right caching headers, possibly using the same methodology, is a
more significant win. IMHO :-)

2) From a more concrete PoV, I'm not sure this code copes well with
content the back-end explicitly marks as non-cachable (i.e. ttl=0).
There may be good reasons for a back-end to do this (possibly not in
/your/ app, but you are presenting it as having wider applicability
than just your situation, hence maybe caveats should be made more
visible) which are irrespective of the time it took to generate the
content.

Anyway, thanks for introducing the concept! Sorry if this looks a bit
negative - it's not really meant to come over as such :-)

Jonathan
--
Jonathan Matthews
London, Oxford, UK
http://www.jpluscplusm.com/contact.html

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


TFigueiro at au

Mar 12, 2012, 3:21 PM

Post #3 of 3 (509 views)
Permalink
RE: Using varnish to increase the cache time of slow pages [In reply to]

Hi, Jonathan. Thanks for the feedback!

> However, I have a couple of quibbles with this *implementation*:
>
> 1) Every bit of logic you embed into VCL is something you have to work at

It's fair to note that other web framework engines seem to use the X-Runtime header for this purpose.

But yes, I agree, you might have to implement that in your backend.

> munging the TTL in VCL!), fixing your back-end's code so it outputs the
> right caching headers, possibly using the same methodology, is a more
> significant win. IMHO :-)

Ah! No need to put salt in our sores. :)

What typically happens is that new features are prioritised over improving performance. I think this is a sad reality in many companies.

What little effort goes into performance ends-up being "spread" across the application. If you have editors complaining about content freshness you can now target these specific pages.


> 2) From a more concrete PoV, I'm not sure this code copes well with
> content the back-end explicitly marks as non-cachable (i.e. ttl=0).

We have specific code in our VCL for this and assumed everyone else does. I should have mentioned that when this excerpt runs we have already 'passed' content which is not cacheable.

> Anyway, thanks for introducing the concept! Sorry if this looks a bit
> negative - it's not really meant to come over as such :-)

Not negative at all, they were all good points and I appreciate you taking the time to ping back.


Cheers


______________________________________________________
CONFIDENTIALITY NOTICE
This electronic mail message, including any and/or all attachments, is for the sole use of the intended recipient(s), and may contain confidential and/or privileged information, pertaining to business conducted under the direction and supervision of the sending organization. All electronic mail messages, which may have been established as expressed views and/or opinions (stated either within the electronic mail message or any of its attachments), are left to the sole responsibility of that of the sender, and are not necessarily attributed to the sending organization. Unauthorized interception, review, use, disclosure or distribution of any such information contained within this electronic mail message and/or its attachment(s), is (are) strictly prohibited. If you are not the intended recipient, please contact the sender by replying to this electronic mail message, along with the destruction all copies of the original electronic mail message (along with any attachments).
______________________________________________________
_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Varnish misc RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.