By default, FlyingPress automatically determines whether a page should be cached based on factors like user status, query parameters, cookies, etc. However, if you need to apply custom logic to control caching behavior, you can use the flying_press_is_cacheable
filter.
Where to add this code
Add the filter in:
Your theme’s
functions.php
fileA custom plugin
A plugin like Code Snippets
Example: Conditionally skip caching
add_filter('flying_press_is_cacheable', function ($is_cacheable) {
// Example: Don't cache if a specific query parameter exists
if (isset($_GET['nocache'])) {
return false;
}
// Example: Don't cache a specific path
if (strpos($_SERVER['REQUEST_URI'], '/no-cache/') === 0) {
return false;
}
return $is_cacheable;
});
Notes
Return
false
to prevent caching for the current requestReturn
true
only if you are certain the request is cacheableAlways return the original
$is_cacheable
if your condition doesn't apply