How often is the cache cleared?
This article lists the scenarios and actions for which WP Rocket automatically runs full cache deletion and partial cache deletion, as well as instructions on how to disable automatic cache clearing.
In this article
When does WP Rocket clear the cache?
The most common triggers for full or partial cache deletion are:
- Changes to WP Rocket settings:
The cache will be cleared automatically when you activate, deactivate or edit the exclusions of certain options in WP Rocket which affect the frontend of your site, such as File Optimizations.- Remove Unused CSS, Optimize critical images and Automatic Lazy Rendering
When the Used CSS or the Priority Elements are cleared, manually or automatically, for all the site (full site deletion), or for specific pages (partial cache deletion).
- Remove Unused CSS, Optimize critical images and Automatic Lazy Rendering
- Cache Lifespan:
On the Cache settings tab you can specify a Cache Lifespan. Only cache files older than the specified lifespan will be deleted. A cron job will run every hour to check which files should be deleted. - New content:
When you publish new content or update/edit existing content, the cache for that post/page, the homepage, as well as related content (e.g. taxonomy archives) will be cleared and (if your settings allow) it will be preloaded afterwards. - For hosting/caching compatibilities: to keep the caches in sync (e.g. on WP Engine and others).
- After the dynamic lists of exclusions are automatically imported each week, or manually by clicking on the "Update lists" button.
Full cache deletion
These WordPress actions trigger full cache deletion:
- updating WP Rocket, depending on the type of changes included in the new version
- changing/updating current themes and parent themes (of child themes)
- updating navigational menus
- updating theme options
- creating/updating/deleting sidebar widgets
- creating/updating/deleting categories, tags, or permalink structures
- creating/updating/deleting terms registered as 'public'
- updating/activating/deactivating plugins when Elementor’s CSS Print Method is set to External File, and Element Caching is set to Default or Active
- when any options are saved in the Customizer
- when the Avada theme clears its own cache
- When any snippet using the
rocket_clean_domain()
function is triggered, such as this cron job
Developers, you might want to look here for which WordPress actions WP Rocket hooks into for cache clearing.
Partial cache deletion
Actions that will trigger partial cache deletion:
- creating/updating/deleting posts, pages, or public custom post types
- creating/updating/deleting comments on a post
- If User Cache is enabled and a user is updated or deleted, only the cache of that user will be deleted. (If you have activated the helper plugin to use the same cache for all logged-in users, these purge actions do not apply).
- Related content: when updating a post, the homepage, the homepage feed, the next and previous post (by ID and in the same category), the posts page, the post type archive page, the author page, and all the post ancestors will be purged too. When using WooCommerce, saving a product variation will trigger the purge of the parent product.
- When any snippet using the
rocket_clean_post()
function is triggered.
Disable automatic cache clearing
It is technically possible to prevent WP Rocket from clearing the cache. Here’s how:
Disable all automatic cache clearing
Heads up! Altering automated cache management can result in outdated content somewhere on your website. Proceed with caution!