Create Different Cache Files with Dynamic and Mandatory Cookies
In this Guide
Some plugins may be using cookies to set dynamic information about a user and differentiate content accordingly.
For example, a third party plugin may set a cookie to detect and store your country, in order to show you content in your specific language. A problem can occur with caching if the plugin is trying to dynamically change the content using PHP. PHP does not run on a cached page, so even if the cookie is set correctly, the content won't change and this will result in incorrect content being displayed.
Filters for developers
If you are the plugin developer you can use these in your code to create compatibility with our plugin. They can be used simultaneously if necessary, or either can be used alone depending on your circumstance.
This creates a cache file for each value of a specified cookie.
This prevents caching until the specified cookie is set
An example of how these filters work can be seen in our compatibility with the Aelia Currency Switcher plugin.
This produces cache files like the following, with the cookie value added to the filename:
Helper plugin for customers
How to use it
1. Download the helper plugin, unzip it and open the PHP file in a text editor.
2. You need to know the name of the cookie storing the dynamic information. You can find this in the developer tools of your browser. If you're not sure how to do this, contact the plugin developer and ask them :)
In the screenshot below the cookie name is:
3. Place the cookie name in line 21 of the plugin.
define( 'WPROCKETHELPERS_CACHE_DYNAMIC_COOKIE', 'your-cookie-id-here' );
define( 'WPROCKETHELPERS_CACHE_DYNAMIC_COOKIE', 'yith_woocompare_list' );
4. Zip up the plugin and install/activate it on your site.