Bypass cache when add to cart ?

Per Buer perbu at varnish-software.com
Wed Dec 23 21:56:44 CET 2015


Hi,

Sure. Here is a hint.

Read through the the relevant parts of the Varnish Book or varnish-cache.org's
"Users Guide". What you're looking for is "passing" certain requests.
You'll control this in vcl_recv and the part that tests on the query string
will look something like this:

if (req.url ~ "\?.*foo=bar") {
    return(pass);
}

You might want to have a look at the cookie vmod, especially if you
struggle with regular expressions.

Per.

On Wed, Dec 23, 2015 at 7:56 PM, Xavier Cardil Coll <info at elsitar.com>
wrote:

> No one knows then ? Not even a hint or something ?
>
> 2015-12-23 13:15 GMT+01:00 Xavier Cardil Coll <info at elsitar.com>:
>
>> Also, how to write a function to bypass cache entirely when a user logs
>> in ?
>>
>> 2015-12-23 12:39 GMT+01:00 Xavier Cardil Coll <info at elsitar.com>:
>>
>>> On Nginx cache, you can do this to avoid keep on caching when you add
>>> something to the cart in Woocommerce :
>>>
>>> Skip cache for WooCommerce query string
>>>
>>> if ( $arg_add-to-cart != "" ) {
>>>       set $skip_cache 1;
>>> }
>>>
>>> Skip cache when WooCommerce cart is not empty
>>>
>>> if ( $cookie_woocommerce_items_in_cart != "0" ) {
>>>     set $skip_cache 1;
>>> }
>>>
>>> How can you do this in Varnish ? With this config, wich was made
>>> specifically for Wordpress + Woocommerce, when you add something to cart,
>>> cache is not disable store wide so you get a mix of cached and non cache
>>> pages, cart gets emptied : http://pastebin.com/TuYeMtUZ
>>>
>>> --
>>>
>>> ELSITAR
>>>
>>>
>>>
>>
>>
>> --
>>
>> ELSITAR
>>
>>
>>
>
>
> --
>
> ELSITAR
>
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>



-- 
*Per Buer*
CTO | Varnish Software AS
Cell: +47 95839117
We Make Websites Fly!
www.varnish-software.com
<http://info.varnish-software.com/signature>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20151223/d353ff68/attachment.html>


More information about the varnish-misc mailing list