[Varnish] #444: allow to handle non-GET req in vcl_miss
Varnish
varnish-bugs at projects.linpro.no
Fri Feb 13 01:17:15 CET 2009
#444: allow to handle non-GET req in vcl_miss
--------------------+-------------------------------------------------------
Reporter: hajile | Type: enhancement
Status: new | Priority: normal
Milestone: | Component: build
Version: trunk | Severity: normal
Keywords: |
--------------------+-------------------------------------------------------
Right now the request is forcibly set to be 'GET'.
As far as I understand the reason http_FilterHeader(sp, HTTPH_R_FETCH)
forces request to be 'GET' is to correctly cache objects for 'HEAD'
requests.
This may be better done in default vcl or somewhere else.
This is not complete patch, it works for me, but it'll break some setups.
In essence, all this is needed to invalidate a cache object when
POST/DELETE/PUT arrives. This is very useful feature to transparently
cache REST-ful services, which are very popular today.
See an example .vcl below, after patch sketch
@@ -650,7 +660,7 @@
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);
- http_FilterHeader(sp, HTTPH_R_FETCH);
+ http_FilterHeader(sp, HTTPH_R_PASS);
VCL_miss_method(sp);
AZ(sp->obj->cacheable);
switch(sp->handling) {
----------------------------------------
backend test {
.host = "127.0.0.1";
.port = "8081";
}
sub vcl_recv {
if (req.request == "POST" || req.request == "PUT" || req.request ==
"DELETE") {
lookup;
}
}
sub vcl_hit {
if (req.request == "POST" || req.request == "PUT" || req.request ==
"DELETE") {
set obj.ttl = 0s;
set obj.cacheable = false;
pass;
}
}
sub vcl_miss {
if (req.request == "POST" || req.request == "PUT" || req.request ==
"DELETE") {
pass;
}
}
--
Ticket URL: <http://varnish.projects.linpro.no/ticket/444>
Varnish <http://varnish.projects.linpro.no/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list