Skip to content
Back to Blog
Performance11 min read

How to Set Up WordPress Cache in 10 Steps (2026)

A step-by-step walkthrough to configure WordPress caching from scratch, covering plugin installation, object cache, CDN integration, and verification.

Written by Abdul AbrorTechnical Hosting Support Engineer
How to Set Up WordPress Cache in 10 Steps (2026)
On this page

Caching cuts WordPress load times by storing pre-built copies of your pages, database queries, and assets. You skip the expensive PHP execution and database round-trips on every hit. In the support tickets I handled, a properly configured cache typically dropped Time to First Byte from three seconds to under 400 ms—sometimes faster.

This guide walks you through ten concrete steps to set up WordPress cache, from plugin choice to verification. You'll configure page cache, object cache, browser cache, and CDN. By the end you'll have a measurable speed improvement and know exactly which levers to pull when something breaks.

Step 1: Pick a caching plugin and install it

Start with a page-caching plugin. Three reliable options dominate shared hosting and VPS environments: WP Super Cache, W3 Total Cache, and WP Rocket. WP Super Cache is free and simple; W3 Total Cache is free but complex; WP Rocket is paid and polished.

For most users I recommend WP Super Cache if you're on a budget or WP Rocket if you want one-click setup. W3 Total Cache shines when you need fine control over every cache type, but its UI overwhelms beginners.

Install from the WordPress admin dashboard:

Plugins → Add New → search "WP Super Cache" → Install Now → Activate

Or upload a purchased .zip file if you bought WP Rocket. The plugin adds a new settings page under Settings → WP Super Cache or Settings → WP Rocket.

Step 2: Enable page caching

Page caching writes static HTML to disk so Apache or Nginx can serve it without loading WordPress at all. Open your plugin's settings and flip the switch.

In WP Super Cache, navigate to Settings → WP Super Cache → Advanced and check "Enable Caching". Choose "Use mod_rewrite to serve cache files" if your server runs Apache with mod_rewrite; it's the fastest method. Click Update Status.

In WP Rocket, caching turns on the moment you activate the plugin. No extra toggle.

Verify by visiting your homepage twice in a private window. View the HTML source; many plugins insert an HTML comment near the closing </html> tag that says "Cached by WP Super Cache" or "Served from WP Rocket cache."

Step 3: Set cache expiration and preload

Decide how long cached pages live before regeneration. A blog that updates once a week can cache for 24 hours; a news site might expire every hour.

In WP Super Cache → Advanced, set "Cache Timeout" in seconds (3600 = one hour, 86400 = one day). Enable "Preload mode" and set an interval; the plugin will crawl your sitemap and rebuild cache files on a schedule so visitors always hit warm cache.

In WP Rocket → Preload, enable "Activate Preload" and enter your sitemap URL (https://yoursite.com/sitemap_index.xml if you use Yoast or Rank Math). WP Rocket will walk every URL and generate cache files in the background.

Preloading matters most after a full cache purge or a post publish. Without it, the first visitor to each page pays the full PHP cost.

Step 4: Configure object cache with Redis or Memcached

Page cache handles HTML; object cache handles database query results, API responses, and WordPress transients. Redis and Memcached are in-memory key-value stores that live outside PHP, so they persist across requests.

Check if your host provides Redis. Many managed WordPress hosts (Kinsta, Cloudways, GridPane) include it. On a VPS, install Redis:

sudo apt update
sudo apt install redis-server php-redis
sudo systemctl enable redis-server
sudo systemctl start redis-server

Then install the Redis Object Cache plugin by Till Krüss. Activate it, navigate to Settings → Redis, and click "Enable Object Cache." The plugin drops a object-cache.php file into wp-content/ and routes all WordPress cache calls through Redis.

If you see a green "Connected" status, you're done. If it fails, check that PHP has the Redis extension (php -m | grep redis) and that Redis is listening on 127.0.0.1:6379.

Memcached setup is similar but uses the Memcached daemon and php-memcached extension. Redis is more common in 2026 hosting stacks, so default to that unless your host specifically provisions Memcached.

Step 5: Enable browser caching with .htaccess or Nginx config

Browser caching tells visitors' browsers to store CSS, JS, and images locally for days or weeks. You set Cache-Control and Expires headers.

For Apache, add this block to your .htaccess file in the WordPress root:

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpg "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType application/pdf "access plus 1 month"
  ExpiresByType font/woff2 "access plus 1 year"
</IfModule>

For Nginx, edit your server block (often /etc/nginx/sites-available/yoursite.conf) and add:

location ~* \.(jpg|jpeg|png|gif|webp|svg|css|js|woff2|pdf)$ {
  expires 1y;
  add_header Cache-Control "public, immutable";
}

Reload the web server (sudo systemctl reload apache2 or sudo nginx -s reload). Most caching plugins also write browser-cache headers automatically, so you might skip manual config if WP Rocket or W3 Total Cache already handles it.

Step 6: Minify and combine CSS/JS

Minification strips whitespace and comments from stylesheets and scripts; combination merges multiple files into one, cutting HTTP requests. Overdoing it can break themes that rely on specific load order, so test after enabling.

In WP Rocket → File Optimization, check: - "Minify CSS files" - "Combine CSS files" - "Minify JavaScript files" - Optionally "Combine JavaScript files" (disable if you see JS errors) - "Load JavaScript deferred" to prevent render-blocking

Save and clear cache. Visit your site; if the layout breaks or scripts fail, uncheck "Combine JavaScript files" or exclude specific handles (jQuery, theme scripts) from the combine list.

In W3 Total Cache → Minify, the interface is more granular. You can manually list which CSS and JS files to minify or combine. It takes longer to configure but gives precise control if a particular plugin conflicts.

Step 7: Integrate a CDN for static assets

A CDN (content delivery network) caches your images, CSS, and JS on edge servers worldwide, serving them from the location nearest each visitor. This cuts latency and offloads bandwidth from your origin server.

Cloudflare is the easiest free CDN. Sign up, add your domain, and update your nameservers at your registrar to Cloudflare's. Once DNS propagates, Cloudflare proxies all traffic and caches static assets automatically.

In WP Rocket → CDN, enter your Cloudflare-proxied domain (or a subdomain like cdn.yoursite.com if you set up a CNAME). WP Rocket will rewrite asset URLs to pull from the CDN.

Alternatively, use BunnyCDN or KeyCDN if you want a pull-zone CDN. Create a pull zone pointing to your origin, then paste the CDN URL into your caching plugin's CDN field. The plugin rewrites https://yoursite.com/wp-content/uploads/image.jpg to https://yourzone.b-cdn.net/wp-content/uploads/image.jpg.

CDN setup is the single biggest win for international visitors. I've seen Australian load times drop from eight seconds to two just by enabling Cloudflare.

Step 8: Exclude dynamic pages from cache

Checkout, cart, account, and admin pages must never be cached—they're user-specific. Most plugins exclude these by default, but verify.

In WP Super Cache → Advanced, the plugin lists accepted query strings and rejected URIs. Confirm /wp-admin/, /cart/, /checkout/, /my-account/ appear in the exclusion list. If you run a membership plugin or custom dashboard, add those paths too.

In WP Rocket → Exclude, add any custom dynamic URLs under "Never Cache URL(s)" and "Never Cache Cookies" (e.g., a cookie set by your forum or LMS). If users report stale profile data or empty carts, you probably cached a page that should have been excluded.

Test by logging into WP admin, then visiting your homepage in the same browser. View source; you should not see a cache comment. If you do, the admin cookie exclusion failed—check your plugin's cookie rules.

Step 9: Purge cache automatically on publish or update

When you publish or update a post, the cache must flush so visitors see the new content. Modern plugins handle this automatically, but older setups sometimes miss it.

In WP Super Cache → Contents, the plugin clears cache on post save by default. You can also purge manually by clicking "Delete Cache."

In WP Rocket, cache purges automatically on post/page publish, plugin updates, and theme changes. You can trigger a manual purge from the admin bar (hover WP Rocket → Clear Cache).

If you run Redis Object Cache, you may need to flush object cache separately. The plugin's Settings → Redis page has a "Flush Cache" button. Some setups tie object-cache purges to page-cache purges via a hook.

Set up a staging site to test changes before pushing to production so you never accidentally purge cache during peak traffic.

Step 10: Verify speed gains with real tools

Finally, measure. Use GTmetrix, Pingdom Tools, or WebPageTest to compare before-and-after load times. Run three tests each and average the results—single tests vary wildly.

Check these metrics: - Time to First Byte (TTFB): should drop under 500 ms with page cache. - Fully Loaded Time: total page weight and requests; CDN and minification should cut this by 30-50%. - Largest Contentful Paint (LCP): Google's Core Web Vital; target under 2.5 seconds.

Use Chrome DevTools Network tab to verify cache headers. Static assets should return 200 (from disk cache) or 304 Not Modified on repeat visits, and show Cache-Control: max-age=31536000 or similar.

If TTFB stays high, object cache or database queries might be the bottleneck. Install Query Monitor to profile slow queries and optimize them with indexes or transients.

What if cache doesn't clear or pages stay stale?

First, check file permissions. Cache directories (usually wp-content/cache/ or wp-content/wp-rocket-config/) need write access for the web server user (www-data on Ubuntu/Debian, apache on CentOS). Run:

sudo chown -R www-data:www-data /var/www/html/wp-content/cache/
sudo chmod -R 755 /var/www/html/wp-content/cache/

Second, confirm your server respects .htaccess rewrites. If mod_rewrite is off or AllowOverride None is set, Apache ignores cache rules. Edit /etc/apache2/sites-available/yoursite.conf and ensure AllowOverride All inside the <Directory> block.

Third, check for conflicting plugins. Two caching plugins will fight; deactivate one. Security plugins (Wordfence, iThemes Security) sometimes strip cache headers or block preload requests—whitelist your caching plugin's user agent.

Fourth, CDN stale cache can persist even after origin purge. Log into Cloudflare or your CDN dashboard and purge the CDN cache manually. Most provide an API endpoint you can call from a cron job or deployment script.

FAQ

Do I need both page cache and object cache?
Yes, if you want maximum speed. Page cache handles anonymous traffic; object cache speeds up logged-in users, admin, and complex queries that bypass page cache.

Will caching break my WooCommerce cart?
Not if you exclude /cart/, /checkout/, and the woocommerce_items_in_cart cookie. All major caching plugins exclude WooCommerce pages by default.

Can I use Cloudflare as my only cache?
Cloudflare caches static assets well but doesn't cache HTML by default on free plans. Pair it with a WordPress plugin for full coverage.

How often should I purge cache?
Never manually unless you're debugging. Let the plugin auto-purge on publish. Frequent purges defeat the purpose of caching.

Monitoring cache hit rates over time

Once cache is live, track hit rates. Redis Object Cache shows hits, misses, and memory usage on its Settings → Redis diagnostics page. A hit rate above 95% is healthy; below 90% suggests your TTL is too short or cache size is too small.

For page cache, tail your web server access logs and grep for cache headers:

tail -f /var/log/apache2/access.log | grep -i "x-cache"

Look for X-Cache: HIT or similar headers if your CDN or server adds them. If you see mostly MISS, either preload isn't working or traffic is hitting excluded URLs.

Set up a weekly cron to report cache size and purge old entries if disk usage climbs. On a busy site, cache directories can balloon to gigabytes; rotate or limit cache age to keep storage in check.

With caching fully configured, your WordPress site should load in under two seconds for most visitors. You've offloaded 80% of the PHP work and can now scale traffic without upgrading your server. Check your cache plugin's settings every few months—WordPress updates sometimes reset options or add new exclusions worth reviewing.