Skip to main content

LiteSpeed Cache Engine

Learning Focus

By the end of this lesson you will understand how LiteSpeed Cache works, how to enable it, and how to verify cache hits for your sites.

What LiteSpeed Cache Does

LiteSpeed Cache can serve cached responses directly, bypassing PHP for repeated anonymous requests. Instead of executing the full application stack on every page load, the server returns a stored copy of the page.

Why It Matters

This is often the biggest single performance win for CMS-based websites because it removes expensive application work from most page views. A properly cached WordPress site can serve pages 10-50x faster than uncached.

Enabling Cache in OpenLiteSpeed

Server-Level

  1. Navigate to Server ConfigurationModules in WebAdmin
  2. Ensure the cache module is loaded
  3. Set Enable Cache to Yes
  4. Configure the cache storage path (default: /usr/local/lsws/cachedata/)

Application-Level (WordPress)

For WordPress, install the LiteSpeed Cache plugin:

# Via WP-CLI (if available)
wp plugin install litespeed-cache --activate

# Or download from the WordPress plugin directory

The plugin communicates with the server's cache engine to control what gets cached, purge on updates, and manage cache rules.

Verifying Cache Status

# Check response headers for cache status
curl -sI https://example.com | grep -i "x-litespeed-cache"

# Expected responses:
# X-LiteSpeed-Cache: hit → Page served from cache
# X-LiteSpeed-Cache: miss → Page generated dynamically
# No header → Cache not active

# Monitor cache directory size
du -sh /usr/local/lsws/cachedata/

Cache Performance Impact

ScenarioTypical Response Time
Cache HIT5–50ms
Cache MISS (PHP execution)200–2000ms
No cache at allEvery request hits PHP
info

Caching is usually the first tuning lever for dynamic OpenLiteSpeed workloads. Before tuning PHP workers, compression, or connection settings, ensure cache is working.

Key Takeaways

  • LiteSpeed Cache eliminates PHP execution for cached pages.
  • This is the single biggest performance improvement for CMS sites.
  • Verify with X-LiteSpeed-Cache response headers.
  • Pair with the WordPress LiteSpeed Cache plugin for CMS sites.

What's Next

  • Continue to Browser Cache to learn about client-side caching headers.