Cache Lifespan

The Cache Lifespan feature in the Cache tab will set the maximum age a cached page can be.

How does it work?

WP Rocket will check the cache files' creation every hour. If at any of those hourly checks, WP Rocket detects that a cache file is "older" than the current Cache Lifespan value, then WP Rocket will delete it, and re-create it afterwards if the Preload is enabled.

The cache files that are removed after the Cache Lifespan check are the ones located at /wp-content/cache/wp-rocket/

However, these actions don't apply for the minified files located at the /wp-content/cache/min/1/ folder.

Which value should I use?

  • The default value for Cache Lifespan is 10 hours.
  • The default value is chosen to avoid any issues with WordPress nonces on your pages. See our related article.
  • In some cases, you can set a longer Cache Lifespan because WP Rocket will automatically clear the cache when content is updated and in other cases. This would be safe in cases where most of your site's pages are not using nonces or there isn't content globally present on many pages that would need to be refreshed. If you're unsure about this, using the default value is recommended.
  • You can use 0 if you want to disable the automatic cache clearing triggered by Cache Lifespan.
  • You can switch to Hours or Days by clicking on the Hours button, as shown below:

    Heads up: The Cache Lifespan just can be set globally affecting all of your pages. It can't be set on specific pages with different values.

    Technical notes

    • Cache Lifespan feature will not work on hosting platforms where WP Rocket caching is disabled, such as WP Engine, Kinsta,, etc. For the full list check Hosting Compatibility article.
    • The hourly check is done using a cron job named rocket_purge_time_event

    An admin notice regarding a Scheduled Cache Purge failed task can appear when:

    • The cron task runs out of schedule due to a long queue of other cron tasks or WP Cron not being triggered. However, the event should run at later time. This should be treated as a false positive warning.
    • WP Cron is not working properly. See more.

    When to use this feature

    A common example of when the Cache Lifespan feature is useful is when there's a widget on most or every page of your site and you want to refresh its content every given hours.

    Note: Using a very short Cache Lifespan can cause CPU overload due to very frequent cache files generation when WP Rocket's Preload is enabled. If you need to refresh a page's content very frequently we recommend using a cron job, and set a higher Cache Lifespan value for your site in general.

    Also, if you're managing a website which content only require updates on a monthly or yearly basis - basically  static websites - you could set a Cache Lifespan value of several days.

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