2026年11月13日

2026年11月13日

WordPress Caching Plugins: WP Super Cache, W3TC and WP Rocket Setup

This article is a localized edition of the Japanese original. Read the Japanese original

Every time a page is displayed, WordPress runs PHP, reads posts and settings from the database, and assembles the HTML. A caching plugin saves that assembled HTML to a file or similar storage and returns the saved copy on later requests, skipping the work. It helps on busy sites and on sites where the server response (TTFB) is slow.

This article covers the types of cache, basic settings for three popular plugins, and how to exclude pages that must not be cached. Plugin details were checked against official information as of November 2026.

Types of cache

Type What is stored Typical tools
Page cache Fully assembled HTML. Skips PHP and database work WP Super Cache, W3 Total Cache, WP Rocket, LiteSpeed Cache, etc.
Browser cache Makes visitors' browsers keep CSS, JS and images Cache-Control/Expires headers (web server settings or a plugin)
Object cache Stores database query results and similar data in Redis or Memcached Plugins such as Redis Object Cache plus Redis on the server
CDN cache Stores static files (and, depending on settings, HTML) on CDN servers Cloudflare and others

Use only one page caching plugin. With two installed, you can't tell which cache is being served, and their edits to WP_CACHE in wp-config.php and to .htaccess collide. If your server runs LiteSpeed, read LiteSpeed Cache setup first; if your host has its own caching feature, check its documentation first.

How the object cache relates to transients is explained in Object cache vs. transients.

Which plugin to choose

Plugin Price Characteristics
WP Super Cache Free Few settings. Focused on page caching
W3 Total Cache Free (paid version available) Many options: page, browser, object and database caching, minification and more
WP Rocket Paid Basic page caching works as soon as it is activated. Many features such as file optimization

The safe approach is to set up page caching alone first, confirm the effect, and then try optimizations such as minification or JavaScript delay one at a time. Optimization features can break how a site looks.

Setting up WP Super Cache

As of November 2026, WP Super Cache (3.1.x) requires WordPress 6.8 or later and PHP 7.4 or later. Your permalinks must be set to something other than "Plain", and the web server must be able to write to wp-content.

  1. Under "Plugins" → "Add New Plugin", install and activate WP Super Cache.
  2. On the "Easy" tab of "Settings" → "WP Super Cache", choose "Caching On" and save. define( 'WP_CACHE', true ); is added to wp-config.php (add it by hand if the file isn't writable).
  3. Use "Test Cache" on the same tab to fetch the front page twice. If the timestamps match, caching is working.
  4. On the "Advanced" tab, check the following items.
Item Setting
Cache Delivery Method Simple (served by PHP, recommended) or Expert (served by Apache mod_rewrite. It rewrites .htaccess, so a mistake can take the site down)
Cache Restrictions Choose "Disable caching for logged in visitors." (Recommended)

These labels are from version 3.1.5 as of November 2026; the Japanese admin shows the translated equivalents.

If you look at the response headers while logged out, a cached page served by PHP carries a WP-Super-Cache header.

curl -sI https://example.com/ | grep -i wp-super-cache

In Expert mode, when Apache returns the file directly, this header is not added. In that case, check with "Test Cache". For detailed settings, see WP Super Cache setup.

Setting up W3 Total Cache

W3 Total Cache has many options, so start by enabling only Page Cache under "Performance" → "General Settings".

Item How to set it
Page Cache method "Disk: Enhanced" on shared hosting. On a VPS where Redis or Memcached is available, you can choose those too
Minify Off at first. If you enable it, check how every page looks and works. Combining CSS and JS breaks things especially easily
Browser Cache When enabled, adds headers such as Cache-Control to static files
Object Cache / Database Cache Disk-based storage can actually make things slower. Consider them when Redis or similar is available

By default, W3 Total Cache does not serve the page cache to logged-in users. For details, see W3 Total Cache setup.

Setting up WP Rocket

WP Rocket starts page caching as soon as it is activated. According to the official documentation, the cache lifetime (Cache Lifespan) defaults to 10 hours and the mobile cache is enabled by default.

  • Cache Lifespan: WordPress nonces (time-limited check values used in forms and elsewhere) expire 12 to 24 hours after they are created. To keep nonces in cached pages from expiring, the official docs recommend a value under 12 hours. The default of 10 hours is fine.
  • Caching for logged-in users: enable it only when logged-in users also need caching, such as on a membership site.
  • File optimization (minification, JavaScript delay, etc.): enable features one at a time and check how the site looks and works each time.

Some hosting companies disable WP Rocket's page cache in favor of their own caching. In that case, only the optimization features work.

Confirming that caching works

Check the effect of caching while logged out (or in a private window). Most plugins don't serve the cache to logged-in users.

# Measure the response time (TTFB) three times
for i in 1 2 3; do
  curl -s -o /dev/null -w '%{time_starttransfer}\n' https://example.com/
done

If the second and later requests are faster than the first, and the page source or headers carry the plugin's marker (for WP Super Cache, the WP-Super-Cache header), the cache is being served. If you use a CDN, also check the CDN's header (for Cloudflare, cf-cache-status) (Cloudflare CDN setup).

Excluding pages that must not be cached

Caching pages whose content differs per user, such as the cart, checkout, my account or member-only pages, can show one person's information to someone else.

WooCommerce

On the cart, checkout and my account pages, WooCommerce defines the DONOTCACHEPAGE constant and sends headers that prevent caching. The major caching plugins check this constant and don't cache those pages. Still, check in practice that your plugin settings haven't removed these exclusions.

Excluding your own pages

Most page caching plugins respect the DONOTCACHEPAGE constant. Define it before the page is output. nocache_headers() sends headers meant for browsers and CDNs and doesn't necessarily stop a plugin's page cache, so use both.

<?php
/**
 * Exclude specific pages from the page cache.
 * The slugs 'members' and 'mypage' are examples.
 */
add_action( 'template_redirect', function (): void {
	if ( ! is_page( array( 'members', 'mypage' ) ) ) {
		return;
	}
	if ( ! defined( 'DONOTCACHEPAGE' ) ) {
		define( 'DONOTCACHEPAGE', true );
	}
	nocache_headers();
} );

To exclude by URL pattern, enter it in the plugin's settings (in WP Super Cache, "Accepted Filenames & Rejected URIs" on the "Advanced" tab; in W3 Total Cache, "Never cache the following pages" under Page Cache; in WP Rocket, "Never Cache URL(s)").

Purging the cache on updates

All three plugins automatically purge a post's cache, and related pages, when you update the post. When you want to purge it yourself, for example after changing data from outside, call each plugin's function. Check with function_exists() first so it doesn't cause an error where the function doesn't exist.

<?php
/**
 * Purge the cache of whichever caching plugin is in use for a given post ID.
 */
function mysite_flush_post_cache( int $post_id ): void {
	// W3 Total Cache
	if ( function_exists( 'w3tc_flush_post' ) ) {
		w3tc_flush_post( $post_id );
	}
	// WP Rocket (also clears related category and tag archives)
	if ( function_exists( 'rocket_clean_post' ) ) {
		rocket_clean_post( $post_id );
	}
	// WP Super Cache
	if ( function_exists( 'wpsc_delete_post_cache' ) ) {
		wpsc_delete_post_cache( $post_id );
	}
}

You normally don't need to hook this function to save_post, because the plugins already do the same thing. Use it after updating data from WP-CLI or after bulk changes that don't go through the REST API, for example.

Setting browser caching on the web server

This example sets expiry times for static files with Apache's mod_expires, without a plugin. Put it in the site's .htaccess (or the VirtualHost configuration).

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 30 days"
    ExpiresByType application/javascript "access plus 30 days"
    ExpiresByType image/webp "access plus 30 days"
    ExpiresByType image/png "access plus 30 days"
    ExpiresByType image/jpeg "access plus 30 days"
</IfModule>

WordPress appends ?ver= to the URLs of theme and plugin CSS and JS files, so when a file is updated its URL changes and the old cached copy isn't used. If you use W3 Total Cache's Browser Cache or WP Rocket, don't write the same settings twice.

Troubleshooting

Symptom What to check
Caching doesn't work Are you testing while logged in? Is WP_CACHE in wp-config.php? Does it overlap with another caching plugin or the server's cache?
Updates don't show up Is a CDN or server cache still holding the old copy? Run the plugin's "clear cache" action
Layout breaks or buttons stop working Disable minification, combining and JavaScript delay, then turn them back on one at a time
Form submissions fail The nonce in the cached page is stale. Exclude the form page or set the lifespan under 12 hours
Other people's information is visible Exclude the page immediately and clear the entire cache

Summary

  • Stick to one page caching plugin, and start by enabling only page caching to confirm the effect.
  • Check while logged out, looking at headers and response times.
  • Exclude pages whose content differs per user with DONOTCACHEPAGE or the plugin's exclusion settings. WooCommerce excludes its main pages itself.
  • Enable optimization features (minification, combining, delay) one at a time and check how the site looks and works.

Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)

お気軽にご相談ください

お見積りへ お問い合わせへ
▲