Never Cache Cookies
In this article
About this feature
This option will prevent caching and optimization based on the presence of the specified cookie.
Cookies are commonly used to customize content for website users.
Ideally, content would be updated dynamically by using the AJAX method. Although some widgets/plugins use PHP code instead. PHP doesn’t run on cached pages and therefore the content is being cached.
As a solution, it is possible to prevent cached pages from being served once a specific cookie is set in the browser.
The Never Cache Cookies option in WP Rocket is often used when the items in the cart are updated with PHP code. To prevent wrong display of the number/price of the items it is possible to exclude pages from caching when an item is added to a cart (i.e. a cookie is set by an e-commerce plugin/widget).
How to find the correct cookie to exclude
You can ask the plugin/widget developer what cookies are used.
You can find what cookies are being set using dev tools in the browser:
- Open dev tools in the browser and navigate to the Application tab;
- Check the Cookies in the Storage section;
- Find the Name of the cookies displayed.
How to add cookie ID
Specify the full or partial ID of cookies that, when set in the visitor's browser, should prevent a page from getting cached and optimized.
You can specify the full name of the cookie:
For cookies that change based on session, like
wp_woocommerce_session_21e8ac8c , use partial name: