How to Exclude URL From VarnishNovember 3, 2016


In this KB:

  • What do Varnish Rules do
  • How to Exclude (bypass) URLs from Varnish


Varnish can  improve website performance through caching dynamic content. Generally, ecommerce websites with secure cart pages are not set up for being cached. Through this feature, specific pages can be excluded whenever required.

Click here to find out how to exclude/include cookies in Varnish.

Step 1: Login to Cloudways Console

Login to Cloudways with your credentials.



Step 2: Select the Target Application

Click on “Applications” on the top menu bar. Select the targeted application from the shown list.


Step 3: Check if Varnish is Enabled

From the Application Settings, enable Varnish. If it is disabled from this section, the Vanish settings would not be available for use.


Step 4: Add Varnish Rule

Before proceeding with add the Varnish rules, it is really important that you refer to the following notes:

  • Excluding from Varnish excludes the entire link from varnish to prevent caching on it. If you exclude a link (“/file.php”) then that file would not cache through varnish.
  • If you use a link (“/checkout/”) which is not a complete destination and can have several links after “checkout/” such as “checkout/cart” or “checkout/items” then all links with “checkout/” would not cache through varnish.

Now Select “Varnish Settings”. Then, click “Add New Rule”.


Choose “URL” from the Type drop-down menu that you wish to Exclude. Enter your string in the Value input field. In this example all links using /checkout/ will be excluded from varnish and would not cache content.

Note: Only relative url’s can be excluded from caching (eg: /checkout/) and not absolute url’s (

Tip: Regex can also be used.



Once added, the rule will be visible in the Varnish Settings section. The rule can be edited or removed whenever needed.2016-11-21_16h14_43

Important Note:

You may need to use VARNISH PURGE if objects/urls are previously being cached



8 Responses

  1. Renan says:

    How to pass the cache for a dynamic URL like .. ?add-to-cart= .. ?
    Thanks in advanced.

    • Cloudways says:

      You can use these rules for excluding checkout/ and carting pages/ for all links and for dynamic links as well. However, please note, that our default vcl for Woocommerce Application is already set to exclude checkout and cart cache links. Therefore it is not necessary for you to add these again separately.

      Cloudways Team

  2. Josimar says:

    I have WordPress multisite. I work with subdomain and mapped domains. So I have the following URLs in my network. Example: (sub domain) (sub domain) (mapped domain)

    Is it possible to delete cart pages from wocoomecer for all addresses? Or will it need to be configured one by one? Can I use for example “/ checkout”? Will this work for all domains in my network?


    • Cloudways says:

      Yes you can exclude all carting pages from your multisite for each domain. You can use /checkout in your varnish settings for excluding url. Since the sites are all based on a single network all domains using checkout would be excluded from caching. This is application wide and would effect on all of its domains. If you want to use it for specific domains you can use the whole url for defining it as such.

      In case you still face any issue then please contact our support any time.

      Cloudways Team

  3. Nino says:

    Great feature, thanks. Do I have to include URLs explicitly or does Varnish cache all URLs automaticalle, which are not on the exclude list?

    • Cloudways says:

      When Varnish is enabled, it includes all pages in your site by default. There are some exceptions which we have specified in our VCL such as the Woocommerce cart pages. This feature allows you to Exclude Url’s from your applicaiton which do not require caching for any particular reason depending on your application needs.

      Cloudways Team

  4. Tim Gary says:

    This doc shows a ful URL path including the http://

    The admin area help item says that only relative urls are to be used.

    Which is correct?? One way or another, one place needs an update 🙂

    • Cloudways says:

      Thank you for highlighting this. We have now updated our article. You would be using the relative URL to define the URL’s that need to be excluded from varnish.

      Cloudways Team

Leave a Reply

Still need help? Our support team is waiting to help you. Ask them now