[ Ingeniería sin atajos ]

How to Configure a WordPress Cache System Correctly

Baqueiro Desarrollo Web ·

TL;DR

  • Caching serves ready-made versions of your pages so they don’t have to be processed on every visit. It improves speed a lot, but a misconfigured cache breaks dynamic features.
  • There are 3 types of cache with different jobs: page cache, object cache and browser cache. Each one needs its own configuration.
  • On sites with WooCommerce, a user area or personalized content, some pages should never be cached. Setting up exclusions properly is as important as turning caching on.

«Install a cache plugin to speed up WordPress» is good advice. What almost nobody explains is that, if you don’t configure it properly, it can create problems as serious as the ones it solves.

A misconfigured cache can serve outdated pages, show one user another user’s data, break the WooCommerce cart or make forms fail when submitted. And days can go by before anyone notices.

What caching is and why it makes your site faster

Every time someone visits a WordPress page, the server runs PHP code, queries the database and builds the HTML that’s sent to the browser. That whole process takes time and resources.

A caching system short-circuits that cycle: the first time a page is visited, the server processes it normally and stores the result. Later visits get that copy directly, with no PHP or database involved: the response is much faster and the server handles traffic spikes better.

The problem comes up when a page’s content needs to change (because the user has logged in, has products in their cart or the content is updated often) and the cache keeps serving the old version. That’s why setting up exclusions is as critical as turning on the cache itself. Also keep in mind that caching is just one piece of performance; here are other ways to reduce your website’s response time without touching the code.

The 3 types of cache in WordPress

Page cache

This is the one with the biggest impact on speed. It generates static HTML files of your pages and serves them directly, skipping PHP and the database. On pages without dynamic content, the improvement in response time is usually dramatic.

The key setting is deciding correctly what to exclude. These should never be cached: the WooCommerce cart and checkout, user area pages (my account, profile, orders), any page that changes depending on who’s viewing it and pages that show a confirmation after a form is submitted.

A lesser-known case: many forms carry a temporary security token (the WordPress nonce) that expires after a number of hours. If the page stays cached longer, the form fails when submitted. That’s why WP Rocket renews its cache every 10 hours by default; with other plugins, shorten the cache lifespan on those pages.

Object cache

WordPress runs many database queries to build each page. Object caching stores the results of those queries in memory (usually with Redis or Memcached) so they don’t have to be repeated. It helps most on large stores and user areas, exactly the pages page caching can’t cover.

Not every host offers Redis or Memcached. Managed WordPress hosts usually include it or sell it as an add-on; basic shared plans often don’t have it. Ask your provider before installing anything.

Browser cache

It tells the visitor’s browser to store certain files (images, CSS, JavaScript, fonts) for a set period. On later visits they load from the device itself, and moving between pages gets noticeably faster.

It’s configured on the server (.htaccess on Apache or the Nginx configuration) or from the cache plugin itself.

Which plugin to choose for your case

WP Rocket is one of the most complete cache plugins out there: guided setup, good WooCommerce compatibility, built-in CSS and JavaScript optimization and quality technical support. It’s paid, with an annual license. For sites that are a business channel, the time it saves usually pays for it.

LiteSpeed Cache is free and very powerful if your host runs LiteSpeed servers, which is common among shared hosting providers. Check before choosing it: if your server runs Apache or Nginx, the plugin’s page cache won’t work and you’ll only be able to use its optimization features.

W3 Total Cache is free and has a huge number of settings, but its interface is complex and it’s easy to get wrong without technical knowledge.

If your host already includes server-level caching, don’t duplicate it with a plugin’s page cache: use the plugin only for what the host doesn’t cover.

Step-by-step setup for a standard WordPress site

Step 1: turn on page caching with the right exclusions

In WP Rocket, page caching is enabled as soon as you install the plugin, and the options are on the Cache tab. If your theme is responsive, you don’t need a separate mobile cache. In the advanced rules, add any dynamic URLs that shouldn’t be cached. WP Rocket already excludes the WooCommerce cart, checkout and account pages, but check anyway: other plugins don’t always do it.

Step 2: turn on CSS and JavaScript optimization carefully

Minification strips spaces and comments from CSS and JavaScript files so they weigh less. Some plugins also combine files or delay JavaScript until the user interacts. It improves speed, but it’s the riskiest step: some themes and plugins stop working when their JavaScript is modified or loaded later.

Turn options on one at a time and check that the site still works after each change: menus, forms, cart, sliders. If something breaks, the culprit is usually in the JavaScript settings. And with HTTP/2, combining files adds little.

Step 3: set up browser caching

Turn it on in the plugin or on the server. Set long periods for files that rarely change (images, fonts, theme CSS) and short periods, or none, for anything updated often. Good plugins add a version number to files so that when they change, the browser downloads the new version.

Step 4: turn on preloading

Most plugins can generate the cache for all your pages in advance using the XML sitemap. That way, the first visitor to each page doesn’t get the slow version. Set preloading to run automatically when you publish or update content and, on modest hosting, make sure it doesn’t overload the server if your site has thousands of URLs.

Step 5: make sure caching doesn’t affect logged-in users

This is the most common mistake on sites with a user area: check that logged-in users see their own content, not the cached anonymous page. Most plugins let you skip caching when there’s an active session or create a separate cache per user. To test it, use 2 browsers: one logged in and the other in a private window.

The most common configuration mistakes

  • Caching the WooCommerce cart and checkout, with the risk of showing one customer another customer’s cart.
  • Turning on aggressive JavaScript optimization without testing that the theme and plugins still work.
  • Not setting up automatic cache clearing when content is published or updated.
  • Running 2 cache plugins at once, which interfere with each other.
  • Not clearing the cache (and the CDN cache, if you use one) after major design or content changes.

If you run an online store, this case where we cut a WooCommerce store’s load time from 8 to 2 seconds shows how caching fits in with the rest of the optimizations.

Checklist: cache configured correctly

  • Page caching on, with exclusions defined for dynamic pages.
  • Cart, checkout and account pages explicitly excluded if you use WooCommerce.
  • CSS and JavaScript optimization on, with the site checked after each change.
  • Browser caching configured with appropriate retention periods.
  • Automatic preloading when content is published or updated.
  • Confirmed that logged-in users see their personalized content.
  • A single cache plugin active, with no conflicts with other performance plugins.

Frequently asked questions

Does caching work the same on every host?

No. Many managed hosts implement caching on the server itself (Nginx, Varnish or LiteSpeed), which responds before WordPress even loads and is more efficient than a plugin’s cache. On basic shared hosting, plugin caching is usually the only option.

How often should the cache be cleared?

There’s no universal answer. What matters is that the cache is invalidated automatically when content changes: when a post is published or updated, when a product is edited or when stock levels change. If it works properly, you only need to clear it manually after big design changes.

Can caching stop my changes from showing up?

Yes, it’s a typical symptom of automatic invalidation that isn’t working. Clear the cache from the plugin (and the CDN cache, if you use one) and try a private window to rule out your browser’s cache. If it keeps happening, the invalidation needs a review.

At Baqueiro, we set up WordPress performance infrastructure (caching, CDN and hosting) as a whole, not plugin by plugin. If your site is still slow even with a cache plugin installed, tell us about it and we’ll take a look.

[ Sigue leyendo ]

Más ideas para tu próximo proyecto.

[ Hablemos ]

Tu próximo proyecto empieza con una conversación.

Cuéntanos qué necesitas resolver. Revisamos contigo el alcance y los siguientes pasos.

Cuéntanos tu proyecto