Purging the wrong scope is one of the most common LSCache mistakes on production WordPress sites: a full flush on every post save eliminates the cache warm-up benefit entirely, while no purge at all serves stale content to users. LiteSpeed offers three purge mechanisms — tag-based, URL-specific, and full flush — each suited to a different operational context. This tutorial covers how each works, when to use it, and how to invoke it from the CLI, HTTP API, and the LSCWP plugin dashboard.
How to verify
Before tuning purge rules, confirm your current cache state and the tags attached to cached responses:
# Check cache-control and purge headers on a cached page
curl -sI https://example.com/sample-post/ | grep -iE 'x-litespeed|cache-control'
# LSCWP WP-CLI: show current cache settings
wp lscache-flush all --path=/var/www/example.com/html --dry-run 2>/dev/null || \
wp litespeed-purge all --path=/var/www/example.com/html
# List cache files on disk (OpenLiteSpeed default path)
find /var/www/example.com/cache -name "*.cache" | wc -l
# Trigger a manual single-URL purge via HTTP header (requires trusted IP)
curl -s -o /dev/null -w "%{http_code}" \
-H "X-LiteSpeed-Purge: /sample-post/" \
https://example.com/
# Verify LSCache purge API is active (should return 200 on purge endpoint)
curl -sI -X PURGE https://example.com/sample-post/
What’s happening
LSCache stores each cached response alongside a set of string tags — arbitrary identifiers set by the application via the X-LiteSpeed-Cache-Tag response header. When LSCWP caches a WordPress single post, it attaches tags like post.1234, cat.5, home, and url./sample-post/. A purge by tag post.1234 removes every cached response carrying that tag — the post page, any archive or category page that lists it, and any related widget output — while leaving all other cache entries untouched.
URL purge removes the cached response for a specific path, identified by the request URI. It does not traverse tag relationships, so only the exact URL (and its vary variants, such as mobile vs. desktop) is removed. This is appropriate when you know exactly which page has changed and want a surgical invalidation without the overhead of a tag graph traversal.
Full flush (* tag or the purge_all API) wipes the entire cache storage path for a vhost. On a large site this means all visitors get cache misses for the next several minutes until the cache warms up again, driving PHP and database load back to peak levels temporarily. Full flushes are appropriate for theme changes, PHP version upgrades, or major content restructures — not for routine post saves.
The procedure
1. Tag-based purge via LSCWP (the default and preferred method).
The LSCWP plugin handles tag assignment and purge automatically for standard WordPress content events. In LSCWP > Cache > Purge, you can configure which events trigger which purge scope. The recommended production settings:
| Event | Purge scope |
|---|---|
| Post updated/published | post.<ID> + related category/archive tags |
| Comment approved | post.<ID> only |
| Plugin/theme updated | Full flush (unavoidable) |
| Menu saved | widget tag group |
| Widget saved | widget tag group |
Leave the “Purge All” trigger disabled for post saves unless your theme renders dozens of pages from a single post’s data.
2. Manual tag purge via WP-CLI.
# Purge a single post by ID
wp litespeed-purge post 1234 --path=/var/www/example.com/html
# Purge all posts in a category
wp litespeed-purge term 5 --path=/var/www/example.com/html
# Purge CSS/JS critical assets after theme change
wp litespeed-purge cssjs --path=/var/www/example.com/html
3. URL purge via HTTP header.
LiteSpeed accepts purge instructions via X-LiteSpeed-Purge request headers from configured trusted IPs. Add your management IP to the trusted network in your vhost config:
module cache {
purgeSensitive 0
purgePublicCacheByIp 192.0.2.10
}
Then purge a specific URL:
curl -s -H "X-LiteSpeed-Purge: /shop/product-slug/" https://example.com/
# Returns: X-LiteSpeed-Purge: done
To purge by tag from the HTTP API:
curl -s -H "X-LiteSpeed-Purge: tag=post.1234,tag=cat.5" https://example.com/
4. Full flush via CLI (last resort).
# LSCWP WP-CLI full flush
wp litespeed-purge all --path=/var/www/example.com/html
# Direct filesystem flush (when LSCWP is unavailable)
rm -rf /var/www/example.com/cache/*
# Then signal LiteSpeed to refresh its in-memory cache index
/usr/local/lsws/bin/lswsctrl restart
5. Programmatic purge from application code.
If you are building a custom plugin or integration, emit the tag and purge headers from PHP:
// On response: tag this page
header('X-LiteSpeed-Cache-Tag: product.567, cat.3');
header('X-LiteSpeed-Cache-Control: public, max-age=86400');
// On update: trigger purge (emit header on a request, or use LSCWP API)
if (function_exists('LiteSpeed_Cache_API::purge')) {
LiteSpeed_Cache_API::purge('product.567');
}
Common pitfalls
Purge loops on high-traffic sites. If your cache TTL is short (under 60 seconds) and your purge rules are broad, purge events can arrive faster than the cache can warm up, resulting in a permanently cold cache. Audit with find /var/www/example.com/cache -name "*.cache" -newer /tmp/marker | wc -l after a busy minute; if the count is low, your TTL or purge scope needs adjustment.
WooCommerce cart pages must never be cached. LSCWP excludes cart and checkout by default, but custom themes that render cart state on non-standard URLs will cache those pages unless you add the URL pattern to LSCWP > Cache > Excludes. Serving a cached cart page to a different user is a data exposure issue.
Tag purge requires the tags to have been stored. If the X-LiteSpeed-Cache-Tag header was not present when the response was cached (common when LSCWP was installed after the cache was initially populated), the tag index is incomplete. A full flush followed by a re-warm is the only reliable fix.
purgePublicCacheByIp must be set or HTTP purge silently fails. LiteSpeed will return a 200 response to the purge request regardless, but if the source IP is not in the trusted list the purge is not executed. Always confirm with a second curl -sI on the target URL that the response is now a miss.
Full flush after plugin updates should be followed by a crawl warm-up. Tools like wp cli with a sitemap loop, or a dedicated crawler such as wget --spider, will pre-warm the most critical pages before real users arrive. Without a warm-up, the first traffic burst after a flush drives full PHP render load.
Ongoing purge strategy review, cache hit-rate monitoring, and WooCommerce exclusion audits are part of Stack Harbor’s managed operations for WordPress environments.