Never cache cookies

This article contains information about the Never Cache Cookies feature in WP Rocket's Advanced Rules tab, the common use scenarios, and instructions how to set the cookie to exclude.

In this article

About this feature

This option will prevent caching and optimization based on the presence of the specified cookie.

Common uses

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).

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:

  1. Open dev tools in the browser and navigate to the Application tab;
  2. Check the Cookies in the Storage section;
  3. Find the Name of the cookies displayed.

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:


Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.