Caching POSTs

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


Hi,

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 192.168.80.173 51082 192.168.80.101 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.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20091104/f93c26c3/attachment-0001.html>


More information about the varnish-misc mailing list