The “Exclude from Optimization by Cookie” feature allows you to serve non-cached content to users, based on their cookies. You can do that by entering a cookie name and an optional value.
After that, when a user’s request contains one or more of the excluded cookies, NitroPack won’t serve the user from cache.
Please note that if you’re running NitroPack on one of the officially supported platforms (WordPress, WooCommerce, or OpenCart) you likely won’t need to use this option. NitroPack excludes the necessary cookies on these platforms by default.
If you’re integrating NitroPack on a custom platform - read on. There are other cases where the “Exclude from Optimization by Cookie” feature can help you.
First, a few words about cookies in general.
What Are Cookies?
Cookies are small text files that the web server sends to the user’s browser.
If the browser saves the cookie, the website can tell when future requests come from the same user.
This allows website owners to personalize the experience for repeat visitors, manage their sessions and analyze user behavior.
Different types of cookies exist and each has a distinct purpose. The two most common types are Session cookies and Permanent cookies.
- Session cookies retain information about users during their current session. As long as the browser stays on, session cookies won’t disappear. After the user closes the browser, these cookies are deleted.
- Permanent (or Persistent) cookies retain information about users even after they close their browser. Persistent cookies allow users to save their login info, so they don’t have to re-enter it each time they visit the same website. They also allow the tracking of user behavior over a longer period.
Other types of cookies also exist - same-site cookies, third-party cookies, secure cookies, etc. If you want a deep dive on the topic, check out this detailed guide.
For now, let’s go back to NitroPack’s “Excluded Cookies” feature.
When Should You Use The “Exclude from Optimization by Cookie” Feature?
When you specify a cookie for exclusion, you tell NitroPack not to optimize the content for users with the cookie. Users with the excluded cookie won’t receive content from cache.
This is especially useful in two cases:
1. When users are logged in their profile
2. When users are browsing your eCommerce store and adding items to their cart
In both cases, you likely don’t want to serve them content from cache.
Again, keep in mind that NitroPack will exclude the necessary cookies for WordPress, WooCommerce or OpenCart websites automatically. Also, both cases described above are handled by default for these platforms.
Now, there are tons of other Content Management Systems (CMS), plugins and frameworks that create and use their own cookies. That’s why it’s impossible to provide a complete list of each cookie that should be excluded.
If you’re using a different platform than the four listed above, consider using the “Excluded Cookie” feature. Again, there’s no way to give you a list of cookies for each separate case. You’ll have to figure out which cookies to exclude.
A good rule of thumb is that you don’t want to serve cached content to users who are logged in. Excluding the cookies you send to these users is generally a good practice.
Of course, this might not be the case for absolutely everyone. Always consider your tech stack, problems and goals before excluding any cookies.
Once you decide which cookies to exclude, simply turn on the “Exclude from Optimization by Cookie” feature and enter a cookie name. NitroPack takes care of the rest.
Article is closed for comments.