1. Home
  2. Blog
  3. Performance

Set How Long WordPress Caches Pages and Which Visitors Skip the Cache

Performance

October 19, 2026

Every page cache quietly answers two questions on every request. How long is a cached copy good for? And who should never be handed one? Get the first wrong and visitors see yesterday’s prices or an expired banner. Get the second wrong and a shopper sees somebody else’s cart count, or your cache hit rate collapses because half your visitors bypass it.

Lightify 1.4.0, released on WordPress.org on 18 October 2026, added direct controls for both. Its changelog lists a new option to choose how long cached pages are kept, with a default of 10 hours, and a new option to skip the cache for chosen cookies and user agents. This how-to explains how to set a WordPress page cache lifespan that fits your site, when a cookie or user agent rule is the right tool, and how to prove the result with two curl commands.

How Lightify keeps cached pages fresh already

Before touching the lifespan, it helps to know that expiry is the backup mechanism, not the main one. According to the Lightify docs, page caching writes the finished HTML of a page to disk so the next visitor gets a file instead of a database query and a PHP render, and Lightify purges automatically when content changes:

  • Publishing or editing a post clears that post and the pages that list it.
  • The built-in integrations extend this: saving a page builder template purges the whole page cache, saving an ACF options page purges everything, and a WooCommerce stock change purges the pages showing that product.
  • WPML, Polylang, TranslatePress and Weglot are detected, so purging a post purges every translation of it.
  • Cloudflare (through the official plugin), Varnish and the server caches of hosts such as Kinsta, WP Engine and SiteGround are purged in step.

Manual purges live in the admin bar on any page:

ControlEffect
Purge current pageRebuilds just the page you are viewing
Purge cache and preloadClears everything, then warms it again
Purge pages and preloadClears the page cache only
Purge everything and preloadClears all caches, including optimized assets

So if every change on your site happens through WordPress, a cached page is usually replaced long before it expires. The lifespan matters for the changes WordPress never hears about.

Step 1: Confirm the page cache is active

There is no point tuning a cache that is not serving pages. The Lightify installation guide gives the check:

curl -sI https://example.com/ | grep -i x-lightify

Run it twice. On a working cache the second request should come back from cache. On daftplug.com/, which runs Lightify, a cached homepage answers with x-lightify-cache: HIT.

If the header is missing, the docs list two common reasons. Page caching needs the WP_CACHE constant in wp-config.php, and managed hosts often make that file read-only, so you may need to add it yourself. And on Apache without mod_headers, the header is silently skipped even though caching works, so look for cache files under wp-content/cache/lightify/ before concluding anything is broken.

Step 2: Choose a cache lifespan

The 1.4.0 changelog describes the new behavior: you choose how long cached pages are kept, the default is 10 hours, and expired pages are cleared about once an hour and warmed again in the background. That last part matters. Expiry does not mean the next visitor pays for a slow uncached render, because Lightify rebuilds expired pages itself.

Which changes the lifespan is for

Think about what on your pages can change without a post being saved:

  • A shortcode or widget that prints today’s date, a countdown or “posted 3 hours ago”.
  • Content pulled from an outside service, such as exchange rates, event listings, reviews or social feeds.
  • A “latest posts” block on a page whose own content never changes, if the theme does not trigger a purge for it.
  • Prices or availability updated by an import that writes straight to the database.

Each of these is invisible to automatic purging, so the cached copy lives until it expires.

A starting point by site type

SiteSuggested lifespanWhy
Brochure or service site, edited a few times a monthKeep the default or go longerNearly all changes go through WordPress and trigger a purge
Blog or magazineThe 10 hour defaultPublishing purges listings; the lifespan catches date stamps and widgets
Store with outside price or stock importsShorter, matched to the import scheduleImports may bypass the purge Lightify runs on stock changes
Event or ticket site with countdownsShorter around event daysTime-based text goes stale even when nothing is edited

These are judgement calls, not values from the docs. Start with the default, and change it only when you can name the content that is going stale.

Lifespan is not browser cache expiration

Lightify has a second, older expiry setting that is easy to confuse with this one. Cache Expiration Time in the browser cache section is measured in days (default 10) and controls how long a service worker keeps content on the visitor’s own device. The page cache lifespan controls the copy on your server. If Progressify is active, it owns the service worker and Lightify’s browser cache section shows Handled by Progressify.

Step 3: Review the cookies that skip the cache

Some visitors carry a cookie that means “this page is personal to me”. Serving them a shared cached copy is wrong, so 1.4.0 lets you list cookies that skip the cache. The changelog says WooCommerce cart and session cookies, and the comment author cookie, are included to start. That covers the classic failure where one shopper’s cart count appears in another shopper’s header, and the case where a commenter sees a cached page without their pending comment.

When to add a cookie

Add a cookie to the list when a plugin uses it to show something per visitor that a cached page would get wrong:

  • A membership or course plugin that keeps its own session in a cookie rather than a WordPress login.
  • A currency or region switcher that Lightify does not already handle. The docs say Aelia, YITH and Curcy set a currency cookie that is already part of the cache key, and that Lightify sets a cookie for WCML, so those need nothing extra.
  • A “recently viewed” or wishlist feature that renders into the HTML on the server.

When not to add a cookie

Never add a cookie that almost every visitor has. Consent banner cookies and analytics cookies are the usual mistakes. If 90 percent of your visitors carry the cookie, 90 percent of them skip the cache, and your site behaves as if caching were off.

Step 4: Use user agent rules sparingly

The same 1.4.0 option lets you skip the cache for chosen user agents. A user agent is the string a browser or bot sends to identify itself. Good reasons to add one are rare:

  • A monitoring tool that must see the live, uncached HTML to check something dynamic.
  • An internal tool or integration that reads pages and needs fresh output every time.

Two cautions. First, phones do not need user agent rules: if your theme genuinely serves different HTML to mobile devices, use Separate Mobile Cache instead, and if your theme is responsive, you need neither. Second, Lightify’s own preloader identifies itself with configurable user agents (the docs list the lightify_desktop_user_agent and lightify_mobile_user_agent filters, the mobile default being a Pixel 4 string). Excluding those would stop preloading from warming your cache, so leave them alone.

Step 5: Know what 1.4.0 changed about which requests are cached

Several smaller 1.4.0 changes affect who gets a cached copy, and they explain behavior you might otherwise chase as a bug:

1.4.0 changeWhat you will notice
Requests with unknown query parameters are no longer cachedA URL with a random ?foo= is served fresh, not stored
Tracking parameters still use the normal cached pageCampaign links with UTM tags stay fast
Only the site’s own address is cachedRequests for other host names are not stored
Currency versions are kept only for known currency codesJunk currency values cannot fill your disk with variants
Cached pages are sent compressed when the browser accepts gzipSmaller transfers, plain HTML for clients that do not ask for gzip
Logged-in caching checks the login cookie against the user’s sessionA copied or stale cookie does not unlock someone else’s cached page
Logged-in caching keeps a separate cached page for each userPersonal headers and greetings stay personal
Page caching works on addresses that include a portYou can test caching on a local or staging site such as localhost:8080

The per-user logged-in cache is a change from the documentation, which still describes one copy per WordPress role. Follow the changelog for 1.4.0 and later.

Step 6: Purge, then test like a visitor

The Lightify settings reference is clear that changing a setting does not rebuild cached pages. Use Purge everything and preload from the admin bar after you change the lifespan or the bypass lists, or visitors keep receiving pages built under the old configuration.

Then test from outside your logged-in browser:

# A normal visitor: run twice, expect a cache hit on the second request
curl -sI https://example.com/ | grep -i x-lightify-cache

# A visitor carrying a cookie on your skip list: expect no cached copy
curl -sI -H "Cookie: woocommerce_items_in_cart=1" https://example.com/ | grep -i x-lightify-cache

woocommerce_items_in_cart is a cookie WooCommerce sets when the cart has items. Replace it with the cookie you added. If the second command still reports a hit, check that the cookie name matches exactly and that you purged after saving.

Finally, check from a private browser window on your phone, because a CDN or host cache in front of Lightify can still serve an old copy. The integrations purge supported CDNs and hosts automatically; for Cloudflare without the official plugin, Lightify has no credentials and you purge Cloudflare yourself.

Common mistakes and quick fixes

SymptomLikely causeFix
A date or countdown is wrong for hoursContent changes without a post saveShorten the lifespan or exclude that page under Page Exclusions
Cache hit rate fell after adding a cookie ruleThe cookie is set for most visitorsRemove it; target a cookie only personal visitors carry
Cart count shows on the wrong visitorA cart cookie missing from the list, or a host cache ignoring cookiesCheck the skip list, then the host or CDN rules
Staging site never cachesOlder Lightify on a URL with a portUpdate to 1.4.0 or later
Settings changed but nothing differsOld cached pages still servedPurge everything and preload

A note for sites running Crownify

If you also run Crownify, the DaftPlug SEO and GEO plugin, the 1.4.0 changelog notes that AI crawler visits are still counted when a page is served from Lightify’s cache. A longer lifespan does not hide crawler activity from your reports.

Free and Pro

The Lightify docs describe the free version as a complete caching plugin, with page cache, browser cache, minification, deferred JavaScript, lazy loading and Core Web Vitals monitoring. Pro adds unused CSS removal, delayed JavaScript, WebP conversion and scheduled database cleanup. Pro comes as part of the DaftPlug membership, which covers all five plugins from $37.99 a year for one site with a 14-day money-back guarantee. See the plans on the DaftPlug pricing page.

For the other half of store caching, read how to keep WooCommerce cart and checkout out of your WordPress page cache.