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 (http://domain.com/checkout/).
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.
You may need to use VARNISH PURGE if objects/urls are previously being cached