Let varnish send old data from cache while it's fetching a new one?
Posted
by
mark
on Server Fault
See other posts from Server Fault
or by mark
Published on 2013-06-23T22:34:00Z
Indexed on
2013/06/24
16:25 UTC
Read the original article
Hit count: 183
I'm caching dynamically generated pages (PHP-FPM, NGINX) and have varnish in front of them, this works very well.
However, once the cache timeout is reached, I see this:
- new client requests page
- varnish recognizes the cache timeout
- client waits
- varnish fetches new page from backend
- varnish delivers new page to the client (and has page cached, too, for the next request which gets it instantly)
What I would like to do is:
- client requests page
- varnish recognizes the timeout
- varnish delivers old page to the client
- varnish fetches new page from backend and puts it into the cache
In my case it's not site where outdated information is such a big problem, especially not when we're talking about cache timeout from a few minutes.
However, I don't want punish user to wait in line and rather deliver something immediate. Is that possible in some way?
To illustrate, here's a sample output of running siege 5 minutes against my server which was configured to cache for one minute:
HTTP/1.1,200, 1.97, 12710,/,1,2013-06-24 00:21:06
...
HTTP/1.1,200, 1.88, 12710,/,1,2013-06-24 00:21:20
...
HTTP/1.1,200, 1.93, 12710,/,1,2013-06-24 00:22:08
...
HTTP/1.1,200, 1.89, 12710,/,1,2013-06-24 00:22:22
...
HTTP/1.1,200, 1.94, 12710,/,1,2013-06-24 00:23:10
...
HTTP/1.1,200, 1.91, 12709,/,1,2013-06-24 00:23:23
...
HTTP/1.1,200, 1.93, 12710,/,1,2013-06-24 00:24:12
...
I left out the hundreds of requests running in 0.02
or so. But it still concerns me that there are going to be users having to wait almost 2 seconds for their raw HTML.
Can't we do any better here?
(I came across Varnish send while cache , it sounded similar but not exactly what I'm trying to do.)
© Server Fault or respective owner