Skip to main content

Server Cache (Page Cache)

Server cache (page cache) stores the final HTML output for a URL so repeat requests can be served without running PHP or hitting the database. For most WordPress sites, this is the biggest TTFB win because it removes the entire WordPress bootstrap for cache hits.

What a Cache Hit Looks Like

page-cache-hit-vs-miss.txt
Request -> Web server
-> Cache lookup
HIT: return cached HTML (no PHP/DB)
MISS: run PHP -> WordPress -> DB -> build HTML -> store -> return

What Should (and Shouldn't) Be Cached

Cache is safest and most effective for:

  • Public pages for anonymous visitors (home, posts, categories, product pages)

Cache should be bypassed for:

  • POST requests
  • wp-admin, wp-login.php
  • Logged-in sessions
  • WooCommerce cart/checkout/account
  • Requests that change state (example: ?add-to-cart=)
caution

If you cache personalized pages publicly, you can serve the wrong content to the wrong user. Always treat authentication cookies and cart/account routes as cache-bypass until proven safe.

Implementation Patterns

LiteSpeed has first-class WordPress support through the LiteSpeed Cache (LSCache) plugin.

Minimum baseline:

  • Enable page cache for guests
  • Exclude cart/checkout/account
  • Keep cache purge predictable

Verify with headers:

curl-litespeed-cache-header.sh
curl -I https://example.com/ | grep -i x-litespeed

Typical signals:

litespeed-cache-hit.txt
x-litespeed-cache: hit

Purge Strategy

Cache only works when you purge predictably.

  • Prefer selective purges (page + related archives) instead of purging everything.
  • Purge after theme/plugin updates.
  • If you publish frequently, consider a warmup/crawler to avoid cold-cache spikes.

Example (LSCache via WP-CLI):

litespeed-purge.sh
wp litespeed-purge all
note

WP-CLI purge commands depend on your cache plugin exposing a WP-CLI command.

Common Problems

SymptomLikely CauseFix
Cached pages still slowCache missesCheck bypass rules, query strings, and cookies; verify headers
Logged-in users see cached HTMLMissing cookie bypassBypass when wordpress_logged_in_ is present
Cart/checkout issuesTransactional routes cachedExclude /cart, /checkout, /my-account and test flows
Low hit rateToo many variantsReduce unnecessary varies (device, query strings, language)

What's Next