Just as with regular sites we wish to cache as much as possible of the webshops running WooCommerce. However, we do not wish to cache any of the pages that are part of the order process. (Otherwise all visitors would be seeing each others shopping carts, shipping details etcetera.)

In order to prevent caching of these pages we need to update the Varnish configuration file:

nano /etc/varnish/default.vcl

And add the following lines to it:

# Do not cache WooCommerce checkout and cart stuff.
# Works only with nice permalinks (set voor Engels en set voor Nederlands)
if (req.url ~ "^/(cart|my-account|checkout|addons)") {
    return (pass);
}
if (req.url ~ "^/(winkelwagen|mijn-account|afrekenen|addons)") {
    return (pass);
}
if ( req.url ~ "?add-to-cart=" ) {
    return (pass);
}

See: Configuring caching plugins