WordPress Caching: How It Works and How to Set It Up

Titelbild: WordPress Caching: So funktioniert es und so richtest du es ein

In short: WordPress caching stores finished HTML pages and static files so the server does not have to recalculate them on every request. The most important is a page cache, complemented by browser cache and, if needed, object cache. Dynamic pages such as cart and login must be excluded.

Caching is the most effective single measure for making a WordPress site faster. It often lowers server time from over a second to a few hundred milliseconds and relieves the server at the same time. Still, WordPress caching is often set up incorrectly or misunderstood: several plugins at once, outdated pages after changes or broken functions in the shop are typical consequences. In this article you will learn which cache types exist, how they work together, how to set up the cache correctly and which mistakes to avoid.

If you want to measure the effects, this helps: Understanding PageSpeed Insights. You will find further measures for the load time of the largest element in Improving LCP.

Infographic: WordPress caching with page cache, browser cache and object cache as well as clearing the cache, exceptions for cart and login and the choice between plugin and server cache
Infographic: Cache types and important rules for WordPress caching (click to enlarge)

The infographic shows the three most important cache types as well as the rules for clearing, exceptions and the choice between plugin and server cache. In the text below you will also find the opcode, CDN and server cache.

What is caching and why is it so effective?

Without a cache, a chain of work steps runs on every page view: the server starts PHP, WordPress loads theme and plugins, queries the database, assembles the page and delivers it. That takes time and computing power. With a cache the result is calculated once and stored as a finished file. The next visitor gets this file directly, without PHP or the database being used. The result: much shorter response time (TTFB), lower server load and better Core Web Vitals.

Illustration on WordPress caching

The most important cache types at a glance

1. Page cache

The page cache stores the finished HTML of a page. It is the most important cache for WordPress and has the biggest effect. It works best for pages that look the same to all visitors, i.e. home page, blog posts, service pages and categories.

2. Browser cache

The visitor's browser stores static files such as images, fonts, CSS and JavaScript. On the next visit or page change they do not have to be reloaded. This is controlled via Cache-Control headers. For files with a version number (e.g. style.css?ver=6.7), long periods such as one year are common—if the file changes after an update, WordPress assigns a new version number and the browser automatically reloads it.

3. Object cache

The object cache (for example Redis or Memcached) stores recurring database queries—such as product filters, complex menus, or WordPress options—directly in fast RAM. It helps above all with dynamic pages like WooCommerce shops and member areas that cannot be fully cached as HTML, though it requires server-side support from your hosting provider.

4. Opcode cache

OPcache stores the compiled PHP code. It is active with almost all hosts and should not be switched off.

5. CDN cache

A Content Delivery Network (CDN such as Cloudflare or Bunny.net) stores copies of static files—and via edge caching even entire HTML pages if needed—on servers worldwide close to the visitor. Learn more in our guide Setting up a WordPress CDN.

6. Server cache

Many hosts offer their own cache at the server level, for example with Nginx FastCGI Cache or LiteSpeed Cache (which operates directly on the web server and is controlled via the plugin of the same name). It responds faster than a pure PHP plugin because the page is delivered before PHP even starts. If your host offers this technology, you should prioritize using it. You can also find details in our comparison Managed WordPress hosting.

Plugin or server cache: Which is better?

Both ways work. A plugin is flexible and independent of the host but needs some configuration. A server cache is often faster and lower-maintenance but tied to the hosting. As a rule of thumb: if your host offers a cache, enable it and do without a second page-cache plugin. Use plugins additionally only for optimizations that the server cache does not cover. Two page caches at the same time lead to conflicts, strange errors and outdated pages.

Step by step: Set up the page cache

  1. Create a backup. Always back up before making changes.
  2. Check the existing cache. Is a cache from the host or a plugin already running? Then do not set it up twice.
  3. Enable the cache. Enable the page cache in the plugin or in the hosting panel.
  4. Define exceptions. Cart, checkout, My Account, login, internal search results with URL parameters, and pages with personal data must never end up in the page cache.
  5. Choose the cache lifetime. 10 hours to several days is common. Shorter for frequently changed content.
  6. Enable cache preloading. The plugin visits pages itself so that the first visitor does not hit an uncached page.
  7. Enable browser cache and compression. Usually a checkbox in the settings.
  8. Test. Open the page as a logged-out visitor in a private window, measure the response time and check in the source code or in the headers whether the page comes from the cache.

How to tell whether the page comes from the cache

Open the developer tools in Chrome, “Network” tab, reload the page and click the first request. In the response headers you will find, depending on the system, entries such as “x-cache: HIT”, “x-litespeed-cache: hit” or “cf-cache-status: HIT”. If they are missing or say “MISS” or “BYPASS”, the cache is not serving. A timestamp comment at the very end of the HTML source code also often reveals whether a cache plugin generated the page.

Exceptions: What must never be cached

  • Cart, checkout and customer account (WooCommerce)
  • Login and registration pages
  • Pages with personalized content, such as member areas
  • Form pages with security tokens (WordPress nonces, e.g., in Contact Form 7 or WPForms), since nonces expire after a maximum of 24 hours—therefore limit the cache lifetime to at most 10 to 12 hours to prevent submission errors
  • Search results and pages with query parameters that represent states
  • The preview mode and the back end

Logged-in users should not receive a page cache by default. Good plugins detect this automatically via cookies such as wordpress_logged_in_ or woocommerce_items_in_cart. In online stores this is crucial; read more in WooCommerce too slow.

Clearing the cache: When and how

When content changes, the cache of the affected page should be cleared automatically. Many plugins do this on every post save. Manual clearing is necessary after:

  • Changes to the theme, the design or CSS
  • Plugin updates and theme updates
  • Changes to menus, widgets and global elements
  • Changes to prices or texts that appear on many pages

Think of all levels: page cache, server cache, CDN cache and browser cache. If the old version still appears after a change, a test in a private window helps. If it shows the new version there, the visitor's browser cache is the cause.

Cache and Core Web Vitals

A good cache improves above all TTFB and thus LCP and FCP. It affects INP and CLS only indirectly. Beware of two typical pitfalls: aggressive file optimizations such as combining or delaying CSS and JavaScript can cause layout shifts (CLS) and sluggish click responses (INP). Thoroughly test the layout and interactivity after every change. Read more in Fixing CLS and Improving INP.

Typical cache mistakes and their solutions

  • Several cache plugins: Use only one for the page cache.
  • Old content after changes: Clear the cache, shorten the lifetime, do not forget the CDN cache.
  • Cart shows wrong data: Check exceptions for WooCommerce pages and cookies.
  • Design broken after activation: Test optimization options for CSS and JavaScript one by one and disable them.
  • No measurable effect: Check whether the page really comes from the cache, whether a cookie or parameter prevents caching or whether the cache is warmed up.
  • Login problems: Exclude login URLs and cookies from the rules.

Caching in practice: Three typical scenarios

Scenario 1: Company site with Elementor

A company site with ten subpages and a contact form. A page cache with long lifetime, preload enabled and browser cache is enough here. Exceptions are only the contact form behavior and the login. Particularly important: after every change with Elementor, regenerate the CSS and clear the cache, see Elementor page speed. Result in practice: TTFB from about 1.1 seconds to under 0.3 seconds.

Scenario 2: Blog with new posts every day

On a blog, new posts should be visible immediately, as should the home page, categories and archives. Modern cache plugins automatically clear the affected pages on publishing. Set the cache lifetime to about ten hours and enable preloading so that visitors do not hit slow pages after clearing. Make sure the CDN cache is updated too.

Scenario 3: Shop with cart and account

In the shop the exceptions are crucial. Cart, checkout and account must never come from the page cache. Product and category pages can be cached, but they must be purged immediately after price or stock updates while mini-carts load dynamically via AJAX. An object cache (Redis) is especially valuable here for fast filters and database queries. Find more on this in WooCommerce too slow.

Set up an object cache with Redis

The object cache is worthwhile for shops, member areas and pages with many database queries. Here is how to proceed:

  1. Ask your host whether Redis or Memcached is available and how to activate it.
  2. Install a suitable object cache plugin and enable the connection.
  3. Check in the plugin whether the status says “connected” and the hit rate rises.
  4. Watch the memory. Memory that is too tight causes the cache to be cleared constantly.
  5. Test cart, login and forms for errors.

Note: an object cache does not replace a page cache. It speeds up the calculation of the page; the page cache avoids it entirely.

Cache headers and browser cache in detail

The browser cache is controlled via HTTP headers. The most important are Cache-Control and Expires. A proven recommendation for static files is: cache images, fonts, CSS, and JavaScript with a unique version parameter in the browser for one year (Cache-Control: public, max-age=31536000, immutable—only use immutable for versioned files, as the browser will otherwise not re-request them for a full year). HTML documents, on the other hand, should not be stored permanently in the browser (no-cache) so visitors see page updates immediately while the server page cache handles fast delivery. In PageSpeed Insights, check the hint “Serve static assets with an efficient cache policy”. It shows you which files are still cached for too short a time. Very often these are files from third parties that you cannot influence.

Cache plugins and optimization: What else is useful

Many cache plugins come with further features. Not all are useful, some are dangerous:

  • Minifying CSS and JavaScript: Usually uncritical and saves some data volume.
  • Combining files: With HTTP/2 and HTTP/3 hardly an advantage any more and often a source of errors.
  • Delay JavaScript: Can improve LCP but disrupt menus, forms and pop-ups. Use only with exceptions.
  • Critical CSS: Can speed up the first render but has to be regenerated after design changes.
  • Lazy loading: Useful for images below the first screen, not for the LCP image.
  • Database cleanup: Handy, but should be done after a backup.

Cache and privacy: What you should keep in mind

A page cache stores public pages and contains no personal data as long as the exceptions for login, account and checkout are set correctly. It becomes problematic if personalized content is cached by mistake, such as a greeting with the visitor's name. So check which pages contain dynamic content and test with two different browsers whether everyone sees only their own data. Cookie banners (consent tools such as Borlabs Cookie or Real Cookie Banner) can also bypass caching if they set cookies that the cache plugin mistakenly interprets as a dynamic user state, skipping the page cache. Make sure to use compatible consent plugins that cleanly load external scripts via JavaScript after user consent.

Troubleshooting: When the cache causes problems

  1. Disable the cache as a test. If the problem disappears, the cache is the cause.
  2. Switch off optimization options one by one. Start with delaying JavaScript, then combining and finally critical CSS.
  3. Check the exceptions. Is a page missing from the list of exceptions?
  4. Bypass the CDN. Open the page directly from the server as a test to see whether the CDN cache is the cause.
  5. Read the error log. Look in your host's PHP error log. If a critical error message appears, WordPress: There has been a critical error often helps.
  6. Clear the cache completely and rebuild it. Sometimes individual files are corrupted.

Checklist: Check caching

  • Is exactly one page cache running (server or plugin)?
  • Are cart, checkout, account and login excluded?
  • Is the cache hit visible in the header?
  • Is the browser cache for static files set long?
  • Is there an object cache for the shop or member area?
  • Is the cache cleared automatically after changes?
  • Is preload active?
  • Do menu, forms and checkout work after every change?
  • Were TTFB and LCP measured before and after setup?

When professional help is worth it

Caching seems simple but can be tricky on complex sites with a shop, member area or CDN. Our Pagespeed Boost at $149 sets up caching, browser cache and optimization cleanly and checks that all functions keep running. With Maintenance at $99 per month everything stays in order after updates. You get a first impression with the free check.

Caching in everyday use: What to do after changes

In day-to-day publishing, you most often stumble over the cache when a freshly published change is not yet visible live. Use this 60-second check to isolate the cause immediately: first you save the change and clear the affected page or the whole cache in the cache plugin. Then you check the page in a private window. If you still see the old version there, it is the server cache or CDN cache, which you have to clear in the respective dashboard. If you see the new version there, it is only the browser cache, which you refresh with Ctrl + F5. For changes to CSS or JavaScript you should additionally have the combined files regenerated. This order saves a lot of time and prevents you from searching in the wrong place. Also document which cache levels are active on your site so that you do not have to guess next time.

Caching on multilingual websites

On sites in several languages, the cache has to store each language version separately. If the German version is accidentally delivered to an English visitor, a visible error occurs, which happens mostly with translation plugins. Therefore, when using plugins such as WPML, Polylang, or TranslatePress, verify that your cache plugin stores language directories like /en/ separately and that automatic browser language redirects are not blocked by the cache.

You have to look even more closely at sites with currency switching or country selection. Here the content changes not only through the language but also through prices and taxes. Such areas should either be cached per variant or excluded from the cache.

How to test the settings

  • Open both language versions in a private window
  • After clearing the cache, reload each version once so that it is warmed up
  • Check that translations, prices and links appear in the right language
  • Clear the affected cache after every translation change

This last point is often forgotten. If a translation changes but the cache keeps serving the old page, the error stays visible to visitors even though it is already fixed in the editor.

Conclusion: Cache is the fastest lever, but not automatic

A cleanly set up cache makes WordPress noticeably faster and relieves the server. Choose a page cache, add browser cache and, if applicable, object cache, define clear exceptions, test after every change and clear the cache after updates. That way you benefit from maximum loading speed without risking errors in forms or checkout. You can find further common bottlenecks beyond caching in our article WordPress slow? The most common causes.

Frequently asked questions about WordPress caching

Do I really need a cache plugin?

If your host does not offer a page cache, yes. Without a cache WordPress recalculates every page, which costs time and server power. If your host offers a server cache, you do not need an additional plugin.

Which cache plugin is the best?

That depends on the hosting. On LiteSpeed servers, the free LiteSpeed Cache plugin is unbeatable in efficiency. On Apache or Nginx servers, WP Rocket, FlyingPress, and W3 Total Cache are among the most proven solutions. Regular updates, automatic WooCommerce exclusions, and a clear configuration are what matter most.

How long should the cache be valid?

For most pages, ten hours to a day make sense. For pages that rarely change, also several days, as long as the cache is cleared automatically on changes.

Can caching break my site?

Yes, if exceptions are missing or optimization options are too aggressive. So: create a backup, enable options one by one and test menu, forms and checkout after every change.

What is the difference between clearing the cache and warming it up?

When clearing, stored files are deleted. When warming up, the plugin visits the pages automatically so that the cache is filled again immediately and no visitor hits an uncached page.

Why is my site not faster after caching?

Check whether the page really comes from the cache. Cookies, URL parameters or faulty rules often prevent caching. Images, scripts and hosting can also be the real bottleneck.

Do I also need to consider mobile when caching?

With purely responsive themes, a separate mobile cache is not necessary. However, as soon as you enable features like Remove Unused CSS or separate critical CSS—or if your theme serves distinct mobile elements—you should definitely activate a separate mobile cache.

Does caching also help with high visitor numbers?

Yes, it is even crucial. Cached pages hardly burden the server, so a site with cache survives visitor peaks that would overload an uncached page.

Can I use cache and CDN at the same time?

Yes, that is the usual combination. Make sure that when the cache is cleared, the CDN cache is cleared too so that no old files are delivered.

What does setting up caching cost with you?

The complete setup is part of our PageSpeed Boost for $149. We configure page cache, browser cache, and script optimization tailored to your hosting, and then thoroughly test all key site functions.

Amine Boudounite

About the author

Amine Boudounite

Amin is the founder of Boudmedia and builds WordPress websites, online shops and business sites. In his guides he explains technology, loading speed and visibility so that you can apply them without any prior knowledge.

Contents
Help with your WordPress site?

We take a free look and tell you honestly what is needed and what it costs.

Share post

You might also be interested in

WordPress Backend Slow? How to Speed Up the Dashboard

Wenn das WordPress-Dashboard träge ist: Ursachen und Maßnahmen im Überblick.

Finding and Fixing a WordPress Plugin Conflict

So findest du den Plugin-Konflikt in WordPress und löst ihn ohne Datenverlust.

Google Shopping with WooCommerce: How to Make Your Feed Error-Free

Wie ein sauberer Produktfeed für Google Shopping aussieht und welche Fehler du in WooCommerce vermeiden kannst.

Problems with your WordPress site? We fix them at a fixed price.

  • Free check of your site
  • Honest assessment of what is needed
  • Fixed price before we start
  • Reply within 24 hours on business days
Scroll to Top