Purging on form submit

Rob S rtshilston at gmail.com
Wed Jul 6 12:25:56 CEST 2011


On 06/07/2011 10:26, Nuno Neves wrote:
> how can I get the hiden input value I have that tell varnish that we 
> have a new post?
>
> <input type="hidden" name="canpurge" value="/topic/123-my-topic/" />
>
> I was thinking of something like this:
>
> sub vcl_recv {
>     if (req.request == "POST" && FORM.FIELD == "canpurge) {
>         purge req.http.host == example.com && req.url ~ 
> ^FORM.CANPURGE.VALUE.*$
>     }
> }

Nuno:

Varnish can't see the body of the response.  However, if you're able to 
change the response, you can just add an HTTP header with this 
information.  Then, in vcl_fetch (which is where the HTTP request is 
sent to the backend), you can probably add something like:

sub vcl_fetch {
   if (beresp.http.x-purgepattern) {
     purge("obj.http.host == example.com && req.url ~ " 
beresp.http.x-purgepattern);
   }
}


Rob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110706/3aeaa8c7/attachment-0003.html>


More information about the varnish-misc mailing list