Purging on form submit

Nuno Neves nfn at gmx.com
Wed Jul 6 21:28:39 CEST 2011


Hello,

Using this code I get an error when starting varnish 3.0

The code:

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


The error:

 * Starting HTTP accelerator varnishd
   ...fail!
SMA.s0: max size 256 MB.
Message from VCC-compiler:
Expected ';' got '('
(program line 174), at
('input' Line 52 Pos 11)
    purge ("obj.http.host == example.com && req.url ~ " beresp.http.X-Purge);
----------#---------------------------------------------------------------------------

What do I need to change?

Thanks

Nuno



A 2011/07/06, às 11:25, Rob S escreveu:

> 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
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

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


More information about the varnish-misc mailing list