Skip to content

LiteSpeed Cache for Craft CMS

PLEASE READ

Development on the 3rd party LSCache Purge plugin for Craft CMS has been discontinued:

Per-URL cache busting is now broken in Craft 3.5 because of changes to how template caching works. You will need to nuke the whole cache on save if you are running 3.5+

This plugin is EOL. Minor patches will be issued, but not major functionality overhauls. PR's gratefully received.

We recommend using LSCache with rewrite rules via these instructions if you are using Craft CMS v3.5 or later.

What is LSCache?

LiteSpeed Cache, also called LSCache, is LiteSpeed's more efficient and highly customizable answer to Apache mod_cache and Varnish.

LSCache is built from the ground up and integrated into all LiteSpeed server products. It can:

  • Dramatically speed up dynamic website content, such as PHP pages
  • Provide more efficient handling of static content, such as images
  • Reduce server load

Understanding caching

If you are new to website caching, allow us to demystify a few basic concepts.

What is caching?

Generally speaking, a cache is a mechanism for storing data in such a way that it is easier or faster to retrieve than the original source.

Web applications consist of dynamic pages that are built with PHP or some other method. The pages of these sites don’t exist anywhere in the file system; they are constructed on demand by the web app and then served to the visitor as HTML. Generating these dynamic pages can be resource-intensive and slow.

There are actually several types of caches. LSCache is a "page cache." A page cache's job is to take this dynamically generated web page and store it as a static HTML snapshot. That way, the next time the page is requested by a visitor, the snapshot can be served immediately. Serving a snapshot is much faster and uses far fewer resources than generating the page dynamically does.

How does LSCache work?

Imagine you have an uncached page.

A visitor requests that page, and a few things happen:

  1. LiteSpeed looks for the page among its stored cache objects and does not find it.
  2. LiteSpeed returns a "cache miss."
  3. The web app dynamically generates a static HTML page while the visitor waits.
  4. LiteSpeed serves the static HTML page to the visitor.
  5. LiteSpeed stores the static HTML page as a cache object for later use.

A few minutes later, another visitor requests that same page. Here's what happens:

  1. LiteSpeed looks for the page among its stored cache objects and finds it.
  2. LiteSpeed returns a "cache hit."
  3. LiteSpeed immediately serves the static HTML page to the visitor.

Notice how the web app does not need to regenerate the page once the page has been cached? From this point on, until the cache object expires, any visitors who request that page will not have to wait for the web app.

You can see why caching is good for your visitors and good for your server load!

When used in conjunction with Craft CMS, you can expect significant performance gains with a quick and easy setup. Rewrite rules can be used to customize LSCache's behavior.

With the addition of the 3rd party "Purge Cache" plugin by Scaramanga Agency, cache management is made even more flexible, allowing you to set longer TTLs for your content.

Server-level prerequisites

Obtain a LiteSpeed web server

To use LSCache, you need either LiteSpeed-powered hosting or one of the following LiteSpeed server products:

Configure cache root

LSCache must be set up at the server level before it can be made available to any sites on the server.

Tip

If you are a site owner and you don't have access to your server's admin functions, your hosting provider has likely already completed this setup for you or can help you complete it.

See Configure Cache Root and Cache Policy for instructions.

Install, configure, and use the plugin

Once you've set up your web server and configured the cache root and cache policies, you're ready to install the plugin. The plugin will allow you to configure and manage your LiteSpeed server's cache easily through your site's own familiar admin interface.

Start with Installation, and follow the documentation menu to configure and use the plugin.

Additional support

Community support

If you've explored our documentation and still have questions, you can find assistance from other LiteSpeed users through our community support forums:

Official LiteSpeed support

To be assisted by a LiteSpeed support technician, you can submit a support ticket from the LiteSpeed website's client area or by emailing support@litespeedtech.com.

Note

We're happy to provide limited free support for all LiteSpeed products and offer guidance where documentation may fall short. However, we are unable to offer general system administration support or hands-on assistance.

Should you require individualized configuration support or hands-on assistance with our products, you can order additional services from the LiteSpeed Store.

Thank you for choosing LiteSpeed!

Feedback

Do you have some thoughts about this documentation site? Join our GoLiteSpeed Slack, drop by the #documentation channel, and let us know what you think!