Features Pricing Reviews FAQ
Get Plugin

Caching the 404 Page

3 min read

xSpeed Cache Pro can serve a single cached 404 page. Bots and scanners often hit thousands of URLs that do not exist, and each miss normally makes WordPress render the full 404 template. Caching one shared 404 response lets those requests cost far less.

What this does

Normally the page cache only stores successful pages, so 404s are rebuilt every time. This module opts genuine 404 responses into the cache.

Instead of storing a separate entry for each unknown URL, xSpeed Cache keeps one generic 404 body and serves it for every missing URL. This means a flood of random scanner paths does not fill your cache with junk entries. The correct 404 status is kept, so the response is still a real 404 and not a 200.

You control the module from the 404 Caching panel inside the Advanced Cache group.

Why use it

Automated scanners probe sites for files and paths that are not there. Each of those requests can trigger a full WordPress render of your 404 page, which adds up during a heavy flood.

Because every unknown URL shares one cached 404 body, xSpeed Cache can absorb that traffic with a single stored response. Your server does the render once, then answers the rest of the flood from cache.

Requirements

  • xSpeed Cache Pro active.

How to enable it

  1. Go to the xSpeed Cache settings and open the Advanced Cache group.
  2. Find the 404 Caching panel.
  3. Turn on Cache 404 pages.
  4. Set 404 cache lifetime (minutes) if you want a value other than the default.
  5. Save your settings.

Settings explained

SettingWhat it doesDefault
Cache 404 pagesServes unknown URLs a cached 404 instead of rendering the 404 template every timeOff
404 cache lifetime (minutes)How long a cached 404 lives before regenerating, from 1 to 1440 minutes (24 hours)5

Cache 404 pages

This is the main switch. When it is on, unknown URLs are served a cached 404 body and the correct 404 status is preserved. When it is off, the 404 template is rendered on every miss.

404 cache lifetime (minutes)

This sets how long the shared 404 response stays valid before it is rebuilt. You can enter any value from 1 to 1440 minutes, and 1440 minutes is 24 hours.

The default is kept short on purpose. If you publish content at a URL that used to be missing, a short lifetime means the cached 404 is not shown for long. Cached 404s also purge immediately when your content changes.

Note: The 404 cache uses one shared entry for all unknown URLs, so it does not grow with the number of paths a scanner probes.

Best practices

  • Keep the lifetime short so newly published pages at previously missing URLs are not masked by an old 404.
  • Leave the default of 5 minutes unless you have a specific reason to change it.
  • Enable this if your logs show heavy bot or scanner traffic against nonexistent URLs.

Troubleshooting

A page I just published still shows a 404. The cached 404 clears when you publish content, so this should resolve on the next request. If it lingers, the short lifetime will expire it soon. You can also purge the cache to clear it right away.

My 404 page is being served with a 200 status. That should not happen with this module, because the 404 status is stored and replayed on cached responses. If you see a 200, check whether another plugin is changing the response status.

FAQ

Does this store a separate cache entry for every bad URL? No. It keeps one shared 404 body that is served for all unknown URLs.

Will this hide real pages? No. Only genuine 404 responses are cached, and publishing new content purges the cached 404.

What is the longest lifetime I can set? 1440 minutes, which is 24 hours.

  • How to Enable Page Cache
  • Purging the Cache
  • Caching Search Results