Features Pricing Reviews FAQ
Get Plugin

Caching Search Results

3 min read

xSpeed Cache Pro can cache your internal search-results pages. When visitors search your site, WordPress runs a search query and builds the results page each time. Caching lets popular repeated searches skip that work.

What this does

Search pages use a URL like /?s=your-term. These pages are normally left out of the cache because the search term changes from request to request. This module opts genuine searches back in.

Each distinct search term is cached separately, so /?s=shoes and /?s=boots stay as their own entries. The term is normalized before it is used as the cache key. Empty searches are never cached, and logged-in users are never served from the search cache.

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

Why use it

Some search terms are searched over and over by different visitors. Without caching, each of those searches re-runs the full query and rebuilds the page, even though the results are the same.

Caching the results means repeated searches for the same term are answered from a stored copy. This lowers database and render work for your most common searches.

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 Search Caching panel.
  3. Turn on Cache search results.
  4. Set Search cache lifetime (minutes) if you want a value other than the default.
  5. Save your settings.

Settings explained

SettingWhat it doesDefault
Cache search resultsServes repeated searches from cache instead of re-running the queryOff
Search cache lifetime (minutes)How long a cached search result lives before regenerating, from 1 to 1440 minutes (24 hours)10

Cache search results

This is the main switch. When it is on, repeated searches for the same term are served from cache. Each distinct term is cached on its own, and empty searches and logged-in users are never cached.

Search cache lifetime (minutes)

This sets how long a cached search result 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 because search results shift as content is added or changed. Cached searches also purge immediately when you publish content.

Note: A burst of searches for random terms clears itself. Each random term expires quickly, and publishing content purges the cached searches, so there is no separate cleanup step to run.

Best practices

  • Keep the lifetime short so search results stay close to your current content.
  • Leave the default of 10 minutes unless your content changes very rarely.
  • Enable this if your site gets a lot of on-site searches for the same popular terms.

Troubleshooting

A new post is not appearing in search results. Publishing content purges cached searches, so the next search rebuilds the results. If it still lags, the short lifetime will expire the old entry soon.

Logged-in users see different results. Logged-in users are never served from the search cache, so they always get a live query. This is expected behavior.

FAQ

Is each search term cached separately? Yes. Distinct terms are stored as separate entries, so different searches do not mix.

Are empty searches cached? No. Only searches with a real term are cached.

Are logged-in users affected? No. They are excluded from the search cache and always get live results.

  • How to Enable Page Cache
  • Caching the 404 Page
  • Purging the Cache