Use code PERFMATTERS for an extra 10% off!
  1. Home
  2. Docs
  3. General
  4. How to warm cache in WordPress (preload)

How to warm cache in WordPress (preload)

A page cache only helps once a page has been cached. After you clear the cache, publish a post, or a cached page expires, the next visitor to each page has to wait while WordPress builds it from scratch with PHP and database queries. That slow first load is called a cold cache. Cache warming, sometimes called preloading, fixes this by visiting your pages in the background ahead of time, so each one is already cached and served as static HTML before a real visitor arrives.

The Perfmatters cache warmer requests your public pages after the cache is cleared or on a schedule you set. It works with the Perfmatters disk cache and can also warm a host page cache or a CDN such as Cloudflare. If a purge happens partway through, it picks up any unfinished URLs and requests them again, so the whole site stays warm.

How to the enable cache warmer

Follow the steps below to enable the cache warmer in Perfmatters.

Note: This feature is currently in beta. If you run into any issues, please reach out. We’re always happy to help as we make improvements.

Step 1

Click into the Perfmatters plugin settings.

Perfmatters plugin settings
Perfmatters plugin settings

Step 2

Click on the “Cache” menu.

Perfmatters cache menu
Perfmatters cache menu

Step 3

Under the Warmer section, toggle on “Cache Warmer.”

Enable cache warmer
Enable cache warmer

Step 4

Scroll down and click “Save Changes.”

Warmer schedule

When the cache warmer is enabled, it automatically warms the cache upon clearing the page cache. It also warms the cache when making a content update on an individual URL. However, you may want to run the warmer on a schedule to keep everything cached as much as possible.

Perfmatters has five different schedules you can choose from for cache warming:

  • None (default)
  • Hourly
  • Twice daily
  • Daily
  • Weekly

Follow the steps below to choose a schedule for the cache warmer. It utilizes WP-Cron.

Step 1

Click into the Perfmatters plugin settings.

Perfmatters plugin settings
Perfmatters plugin settings

Step 2

Click on the “Cache” menu.

Perfmatters cache menu
Perfmatters cache menu

Step 3

Under the Warmer section, choose the schedule you want.

Cache warmer schedule
Cache warmer schedule

Step 4

Scroll down and click “Save Changes.”

Warmer sources

You can choose which sources you want the cache warmer to run on. Follow the steps below.

Step 1

Click into the Perfmatters plugin settings.

Perfmatters plugin settings
Perfmatters plugin settings

Step 2

Click on the “Cache” menu.

Perfmatters cache menu
Perfmatters cache menu

Step 3

Under the Warmer section, choose which posts you want to use for your sources. You can also use the “Scan Now” button to see how many posts your selection would include.

Homepage, posts, and pages are included by default. Custom post types will also show here if they are available.

Cache warmer sources
Cache warmer sources

Step 4

Scroll down and click “Save Changes.”

Additional information

Start or stop warmer programmatically

If you need to programmatically start or stop the warmer, you can use our class function: \Perfmatters\Cache\Warmer::start() / ::cancel();

We also have more filters available that you can use to change how the cache warmer works.

Cloudflare APO

You can use the cache warmer feature alongside Cloudflare APO. And we are working on closer APO integrations.

Related Articles