This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

Introducing Cloudways Community Forum. Start Discussions and Get Instant Help From Cloudways Community. JOIN NOW

How to Include or Exclude Cookies From VarnishNovember 3, 2016

 

In this KB

  • What do Varnish Rules do
  • How to Include (allow Varnish to Cache) Cookies
  • How to Exclude (bypass from Varnish) Cookies
  • Important Notes

 

Varnish is a cache service used to cache dynamic content on websites to improve their performance. Some websites such as e-commerce stores with secure cart pages or sessions do not require caching. This feature allows specific cookies to be excluded or included as per your requirements.

Click here to find out how to exclude URLs from Varnish.

Step 1: Select the Target Application

Log into the Cloudways Platform with your credentials. Click on Applications in the top menu bar and then select your target application from the list.

Application Management

Step 2: Check if Varnish is Working

Go to the Application Settings section under the Application Management area. Make sure that Varnish is Enabled. If it is disabled from this section, then the Varnish settings would not be available.

applications-settings

Step 3: Add Varnish Rule

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

  • Including Cookies such as $cookie_name (user_243545) would include it in our Varnish VCL and would cache its data. Cookies that are generally included are those that have the same variables, calls, sessions being represented for each client. These do not need to be regularly updated and therefore can be included in varnish cache.
  • Excluding cookie such as $cookie_name (user_2545) would prevent the cookie strings caching and would allow them to work bypassing caches. This is used when cookies create different sessions and calls and are unique. These cookie sessions are regularly updated and therefore are excluded from caching so that the sessions can be properly updated.Now click on Varnish Settings and then click on Add New Rule.

varnish-settings-add-new-rule-cookie-include

Choose the Type (Cookie), Method (Include or Exclude) and add the Value. Then click on Save to finalize the rule.

Tip: The cookie value can be the full cookie or the name. Regex can also be used.

cookie-include-add
Once the rule is added it would be visible in the Varnish Settings tab. The rule can be edited or removed whenever required.

cookie-include-added

Important Notes:

  • You may need to use Varnish Purge if objects/URLs are previously being cached.
Have Questions? Ask From Our Helpful Community

Comments are closed.

Do you still need help?

Our Technical Support team is always at work.