[Varnish] #690: Allow for a negative grace period for internal crawler
Varnish
varnish-bugs at varnish-cache.org
Sat May 1 03:44:28 CEST 2010
#690: Allow for a negative grace period for internal crawler
------------------------+---------------------------------------------------
Reporter: mikeytown2 | Type: enhancement
Status: new | Priority: normal
Milestone: | Component: build
Version: 2.0 | Severity: normal
Keywords: grace |
------------------------+---------------------------------------------------
We use an internal crawler to refresh the pages cache. So if we want
something refreshed very soon but not deleted, this will do it. This
allows us to almost always serve the request from the cache & still have
content updated on a regular basis.
vcl configuration
{{{
if (req.http.user-agent == "our-crawler") {
#HACK
C{ VRT_l_req_grace(sp, -300); }C
} else {
# in case "our-crawler" hasn't refresh the data; this will reduce the
load on the backend
set req.grace = 5m;
}
}}}
patch to cache_hash.c
{{{
--- ./bin/varnishd/cache_hash.c 2009-12-16
00:45:49.000000000 -0800
+++ ./bin/varnishd/cache_hash.c 2010-02-22 11:29:06.000000000
-0800
@@ -293,6 +293,15 @@
grace_o = o;
}
+ if (sp->grace < 0) {
+ sp->grace = -sp->grace;
+ if (o != NULL) {
+ o->ttl = sp->t_req-1;
+ o = NULL;
+ }
+ grace_o = NULL;
+ }
+
/*
* If we have seen a busy object or the backend is
unhealthy, and
* have an object in grace, use it, if req.grace is also
--- ./bin/varnishd/cache_vrt.c 2009-10-23 01:00:09.000000000 -0700
+++ ./bin/varnishd/cache_vrt.c 2010-02-22 11:29:35.000000000 -0800
@@ -534,8 +534,6 @@
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- if (a < 0)
- a = 0;
sp->grace = a;
}
}}}
--
Ticket URL: <http://www.varnish-cache.org/ticket/690>
Varnish <http://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list