Caching POSTs

Rob Ayres quasirob at
Wed Nov 4 12:48:10 CET 2009


I want to cache POSTs but can't get varnish to do it, is it possible? If it
makes it any easier, all requests through this cache will be of POST type.

So far I have changed the line in vcl_recv to look like this:

if (req.request != "GET" && req.request != "HEAD" && req.request != "POST")

This resulted in the first request looking like this:

   10 RxRequest    c POST
   10 RxURL        c /autocomplete/autocomplete.xqy
   10 RxProtocol   c HTTP/1.1
   10 RxHeader     c User-Agent: Test client
   10 RxHeader     c Host: durham:8630
   10 RxHeader     c Content-Length: 84
   10 RxHeader     c Content-Type: application/x-www-form-urlencoded
   10 VCL_call     c recv
   10 VCL_return   c lookup
   10 VCL_call     c hash
   10 VCL_return   c hash
   10 VCL_call     c miss
   10 VCL_return   c fetch
   11 BackendOpen  b default 51082 8630
   10 Backend      c 11 default default
   11 TxRequest    b GET

As you can see it arrives as a POST and gets changed to a GET. After that
all requests go through as "Cache hits for pass" which at least returns data
from the backend even if it isnt cached.

I then added "set bereq.request = "POST";" to vcl_miss which does change the
TxRequest to POST but still doesnt work.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-misc mailing list