Skip to main content

How to keep the cache up to date without scheduled cache cleaning

A common question is whether you need a cron job that runs bin/magento cache:clean full_page or bin/magento cache:flush every day to keep the full page cache fresh. You do not. Magento already updates the pages that change, and a scheduled clean or flush empties the cache that the warmer has filled.


1. Magento clears only the pages that change​

When you save a product, a category, a CMS page, or another entity, Magento clears only the cached pages that show it. Every cached page is stored with cache tags that name the entities on it, for example, cat_p_<id> for a product and cat_c_<id> for a category. On save, Magento removes the pages with the tags of the saved entity:

  • Built-in cache (stored in files or in Redis): Magento removes the entries with these tags from the cache storage.
  • Varnish: Magento sends Varnish a purge request with the same tags.

So the Built-in cache with Redis updates a single product page as precisely as Varnish does. All other pages stay cached, and the warmer warms the cleared pages again.

In addition, every page expires after the time set in TTL for public content at Stores -> Configuration -> Advanced -> System -> Full Page Cache (86400 seconds by default).

note

When Forbid cache flushing = Yes in Caching behaviour, the extension blocks this automatic clearing. Changes then appear on the storefront only after you clear the cache in System -> Cache Management or after the TTL expires. Keep this option set to No if your product and category changes must appear right away.


2. What a scheduled clean or flush actually does​

Neither command refreshes only the outdated pages:

CommandWhat it removes
bin/magento cache:clean full_pageevery page in the full page cache, not only the outdated ones
bin/magento cache:flushthe whole cache storage, including all other data stored in the same storage (for example, the same Redis database)

After each run, the cache is empty: visitors get uncached, slow pages, and the warmer has to warm the whole store again. On a large catalog this can take hours, so a daily clean keeps the cache partly empty most of the time.

Run these commands only when they are needed, for example, after a deployment or after changing the design or configuration.

tip

If you clean the cache to free memory in Redis, set a memory limit (maxmemory) and an eviction policy (maxmemory-policy) in the Redis configuration instead. Redis then removes old entries by itself when the limit is reached. Ask your hosting provider or server administrator to configure it.


3. How the warmer reacts to cleared pages​

  • Cache flushes that go through Magento, together with their reason, are listed on the Cache flushes page. Use it to find what clears your cache. See How to monitor cache flushes.
  • The extension re-checks the status of pages on a schedule. Pages that are no longer in the cache get the Pending status and are warmed again.
  • If the cache is emptied outside Magento, for example, by a redis-cli command, see When the cache is flushed outside Magento.