FlyingPress generates the same cached version of a page even if cookies are present—except for a few built-in exceptions like logged-in users, supported multi-currency plugins, and certain integration cookies.
If your plugin or custom code requires separate cache to be generated based on specific cookies, you can use the flying_press_cache_include_cookies
filter to append those cookies.
Where to add this code
You can add the snippet to:
Your theme’s
functions.php
fileA custom plugin
A plugin like Code Snippets
Example: Append cookies to generate separate cache
add_filter('flying_press_cache_include_cookies', function ($cookies) {
$cookies[] = 'user_location';
$cookies[] = 'test_variant';
return $cookies;
});
How it works
FlyingPress checks if the request contains any of the listed cookie names.
If found, it generates a separate cache key based on those cookies.
This allows you to serve personalized cached pages based on cookie values.
Notes
Only use this filter when necessary, as it increases the number of cached files.
Avoid including frequently changing cookies (e.g., session IDs) to prevent cache fragmentation.
Only cookie names are considered—values are not inspected.