LiteSpeed Cache Settings – A Quick Setup Guide

Last updated: by Janz Nordman
Litespeed Hands On Visual
[1] General
[2] Cache
[3] Purge
[4] Excludes
ADVANCED
[5] Optimize
[6] Tuning

When it comes to optimizing your website, caching is one of the best technology available today. It makes your website extremely fast which will eventually result in less bounce rate, better SEO results, and better conversion. LiteSpeed Cache for WordPress by LiteSpeed Technologies is an all-in-one site acceleration plugin, featuring an exclusive server-level cache and a collection of optimization features. It supports WordPress multisite and is compatible with most popular plugins, including WooCommerce, bbPress, and Yoast SEO. Awesome, isn’t it?

LiteSpeed WordPress Performance

TipsMany of the optimization features can be used when using any of the following web servers: LiteSpeed, Apache, Nginx, etc. The caching features, however, require either free OpenLiteSpeed, commercial LiteSpeed Enterprise Edition, LiteSpeed-powered hosting providers like A2 Hosting, Hostinger, or the new QUIC.cloud CDN.

TipsAre you using an alternative webserver instead of LiteSpeed server technology? When yes, I strongly suggest you consider using WP Rocket WordPress caching plugin. They have over 1 million installations already on production environments, meaning they do something right.

General

Enable LiteSpeed Cache

You can enable LiteSpeed cache settings only when pre-requisites have fulfilled (read above). Otherwise, you should see the corresponding error message. You can peek here to get some overview of how to test the cache. NB! When disabling the cache, all cached entries for your website will be purged.

LiteSpeed Setting Enabled

Automatically Upgrade

Turn this option ON to have LiteSpeed Cache settings updated automatically, whenever a new version is released. However, it is strongly recommended to turn this OFF and apply updates manually.

LiteSpeed Setting Off

TipsFor all the Time-To-Live (TTL) settings you can easily use the default values that are already present. Probably you never need to change those values, because they work already the best optimum way for you. Do not forget to click on “Save Changes” afterward. Please note that the value fields expecting some number value in seconds.

Cache

Cache Mobile

Turn this option OFF when your website doesn’t have either AMP or mobile-specific design/content. For responsive websites turning this option ON is not necessary.

NB! This setting will edit the .htaccess file.

LiteSpeed Setting Off

TipsFor all other settings, you can easily use the default values. Probably you never need to change those values, because they work already the best optimum way for you. Do not forget to click on “Save Changes” when you have changed any of the toggles.

Purge

Purge All On Upgrade

Turn this option ON to have LiteSpeed Cache settings updated automatically, whenever a new version is released. However, it is strongly recommended to turn this OFF and apply updates manually.

LiteSpeed Setting On

Auto Purge Rules for Publish/Update

I strongly do recommend tick the “All pages” option to make sure that nothing isn’t cached when content has updated. Usually, it’s a good practice to purge only pages where the content has changed. On the other hand, people tend to forget such a rule as “Auto Purge“. That’s why the safest bet is to choose purge for all options. Make sure you know what are you doing when choosing another way.

LiteSpeed Purge All

Scheduled Purge URLs

If you have content that is generated by an outside source at a certain time every day, then you might want to purge the page to be sure the outside content is correctly displayed. You can specify a list of URLs (one per line) that will be purged automatically at a certain time of day.

NB! Specifying those URLs is not necessary under normal circumstances.

1. line: https://yourdomain/events/list.php
2. line: /events/list.php

TipsNote that the second URL points to the same URL as the first one.

Scheduled Purge Time

Excludes

Here you can specify the purge time when you have fulfilled the “Scheduled Purge URLs” field.

10:00 PM

Force Cache URIs

You can specify special URIs to force caching regardless of any “non-cacheable” settings that may appear elsewhere. Also, you can overwrite default TTL value when the current value doesn’t satisfy your needs.

NB! You can use special characters “^” and “$“, to indicate the beginning of a string and/or the end of a string e.g. ^/events/list/$.

1. line: /events/list/?category=online 300
2. line: /events/list/?category=classes 600
3. line: /events/list/$

TipsNote that by default events page will use the default TTL caching period. Although, online and classes category will use accordingly 300 and 600 seconds of caching period.

Do Not Cache URIs

You can specify your own URIs to skip caching regardless of any “cacheable” settings that may appear elsewhere.

NB! You can’t use TTL values at the end of URI strings here because this is for caching only.

1. line: /events/list/
2. line: /events/list/$
3. line: ^/events/list

TipsYou can also use special characters “^” and “$” here. This setting is very useful when some REST API calls need to be excluded from the cache mechanism.

Do Not Cache Query Strings

The query string is the part of URI what stays on the right side from “?” symbol e.g. https://www.yourdomain.com/events/list/?category=online where the query string is category=online.

1. line: category

TipsYou don’t want to cache any pages where categories are used.

Do Not Cache Categories

To prevent categories from being cached you can exclude any by entering particular category slug value for this setting. Example https://www.yourdomain.com/category/{category-slug}/ e.g. review.

1. line: category-slug
2. line: category-slug-2

TipsYou can insert multiple category slugs, one per line.

Do Not Cache Tags

To prevent tags from being cached you can exclude any by entering particular tag slug value for this setting. Example https://www.yourdomain.com/tag/{tag-slug}/ e.g. wordpress.

1. line: tag-slug
2. line: tag-slug-2

TipsYou can insert multiple tag slugs, one per line.

Do Not Cache Cookies

This is a list of cookies telling that, do not cache any page where a cookie in this list appears in the request headers. In normal circumstances, you don’t need to use that option.

NB! This setting will edit the .htaccess file.

1. line: yummy_cookie

TipsYou can insert multiple cookies, one per line. Spaces should have a backslash in front of them,\

Do Not Cache User Agents

When a visitor requests a page from your site via one of the listed user agents, they will not be served from the cache. In normal circumstances, you don’t need to use that option.

NB! This setting will edit the .htaccess file.

1. line: Mozilla/5.0

TipsYou can insert multiple user agents, one per line. Spaces should have a backslash in front of them,\

Do Not Cache Roles

When you are an administrator, testing new functionality, you may want to exclude yourself from being served from cache until your testing is done.

LiteSpeed Administrator Role

LiteSpeed Cache SettingsOptimize (Advanced)

Optimize and Tuning is two closely related tabs. Generally speaking, you will find the ON/OFF switches in Optimize, and the customizations that go along with these switches in Tuning.

CSS Minify

Turn this option ON to remove unnecessary or redundant data without affecting how the resource is processed by the browser – e.g. code comments and formatting, removing unused code, using shorter variable and function names, and so on.

LiteSpeed Setting On

CSS Combine

Each CSS file you are using for your website adds time to your page load speed. Sometimes this is unavoidable, however, when turning this option ON you can combine all CSS files together. Use Tuning -> CSS Excludes option when any CSS file needs to be excluded from the combined file.

LiteSpeed Setting On

CSS HTTP/2 Push

Turn this option ON to pre-send internal CSS files to the browser before they are requested.

NB! Connections must use SSL.

LiteSpeed Setting On

JS Minify

Turn this option ON to remove all unnecessary characters from the JavaScript source codes without changing functionality.

LiteSpeed Setting On

JS Combine

Each JS file you are using for your website adds time to your page load speed. Sometimes this is unavoidable, however, when turning this option ON you can combine all JS files together. Use Tuning -> JS Excludes option when any JS file needs to be excluded from the combined file.

LiteSpeed Setting On

JS HTTP/2 Push

Turn this option ON to pre-send internal JS files to the browser before they are requested.

NB! Connections must use SSL.

LiteSpeed Setting On

HTML Minify

HTML minification removes all unnecessary characters from the source code without changing functionality. I do recommend to turn this option ON.

LiteSpeed Setting On

Inline CSS Minify

Minify inline CSS code. I do recommend to turn this option ON.

NB! HTML Minify must be enabled.

LiteSpeed Setting On

Inline JS Minify

Minify inline JS code. I do recommend to turn this option ON.

NB! HTML Minify must be enabled.

LiteSpeed Setting On

Load CSS Asynchronously

Keep this option OFF, otherwise please extract Critical CSS from the rest of the CSS code or leave this job for the LiteSpeed CCSS server. Please be noted that this is an advanced technique and can be quite tricky. Therefore, if you are responsible to maintain or build a rather complex website, this feature is not worth the hassle.

LiteSpeed Setting Off

Load JS Deferred

JavaScript is considered a “parser blocking resource” and hence plays a crucial part in the Critical Rendering Path. I do recommend to use deferred loading for Javascript files whenever possible.

LiteSpeed Setting On

Exclude JQuery

This option improves compatibility with inline JavaScript. When you use the JS Combine feature, it is recommended that this setting remains ON.

LiteSpeed Setting On

DNS Prefetch

Prefetching DNS can reduce latency significantly for your visitors when they click to external links, particularly on mobile networks. Domains should be entered one per line.

1. line: //www.litespeedtech.com
2. line: //www.a2hosting.com

Remove Comments

When JS and CSS files have minified, comments can take up valuable space. I do recommend to turn ON this option of LiteSpeed Cache Settings to strip comments from minified files and make them more efficient to transmit.

LiteSpeed Setting On

LiteSpeed Cache SettingsTuning (Advanced)

Combined CSS Priority

Normally, combined CSS is loaded after external CSS files. Leave this option disabled, because combined local CSS is more likely to have customizations that need to be loaded after the base CSS. Enable this option if you have reason to load combined CSS before other CSS files.

LiteSpeed Setting Off

CSS Excludes

Here you can list down all the CSS files that should not be minified/combined. Both full URLs and partial strings can be used, one per line. Filter with the name litespeed_cache_optimize_css_excludes is also supported. All the elements with an attribute data-no-optimize="1" in HTML code will be excluded.

1. line: https://www.yourdomain.com/wp-content/plugins/cookie-pot/css/cookies.css
2. line: cookie-pot/css/cookies.css

TipsNote that the second file location points to the same resource as the first one.

Combined JS Priority

Normally, combined JavaScript is loaded after external JavaScript files. Leave this option disabled and enable it if you have reason to load combined JavaScript before other JavaScript files.

LiteSpeed Setting Off

JS Excludes

Here you can list down all the JS files that should not be minified/combined. Both full URLs and partial strings can be used, one per line. Filter with the namelitespeed_cache_optimize_js_excludes is also supported. All the elements with the attribute data-no-optimize="1" in HTML code will be excluded.

1. line: https://www.yourdomain.com/wp-content/plugins/cookie-pot/js/cookies.js
2. line: cookie-pot/js/cookies.js

TipsNote that the second file location points to the same resource as the first one.

Remove Query Strings

Removes query strings from static resources. There are rumors that some servers and proxy servers are unable to cache properly when query strings are used. Although this can improve your speed score in services like Pingdom, GTmetrix, and PageSpeed, it can cause a bad user experience for your visitors when you update a particular plugin or theme. Therefore, only use this option when you do not update your WordPress often.

NB! Please remember that query strings are usually there for a reason, especially in the WordPress world.

LiteSpeed Setting On

Remove WordPress Emoji

Browser default emoji will be displayed instead of wordpress.org emoji. I do recommend to turn this option ON when you do not need to use emojis.

LiteSpeed Setting On

Surprisingly Fast Web Hosting

Up to 20X Faster Web Hosting for Your Unique Needs!

By the way, I found an interesting resource to improve your WordPress website. Please read here for further instructions.

4 Comments

  1. Janz Nordman

    Jamie

    Hello Janz

    Our small business is considering moving our online shop to a new platform and so far litespeed server technology seems to be a decent alternative to consider. Currently, we are using Apache servers and wondering is there any significant benefit when switching to litespeed server. Any thoughts?

    • Janz Nordman

      Hi Jamie,

      I can’t promise you anything, because it depends on specific server setup, hence each system may benefit differently. Also, it depends on the monthly visitors and hosting plan, but different reviews and monitorings have shown that LiteSpeed server technology performs far better than Apache and Nginx because LSWS is relatively new and contains both rival’s best architectures. That is one of the reasons why it’s compatible most of the commonly-used Apache features and the migration should be easier. Please be noted that LSWS supports the new HTTP/3 protocol also known as HTTP over QUIC which is a huge step forward in the network topology. All major browser vendors currently adding step by step the new protocol support to their browsers. It’s definitely an interesting server technology solution and supportively suggesting to give it a try. Don’t hesitate to contact me directly via e-mail.

      Happy to advise you,
      Janz

  2. Janz Nordman

    Joel Thomas

    Hey, Can you suggest the optimal Litespeed cache settings with Cloudflare CDN?
    Thanks!

    • Janz Nordman

      Hi Joel,

      I’m happy to advise you. It’s hard to provide you the optimal LS Cache Settings without knowing the origin server setup requirements. What I can suggest is to set up a staging environment for your website and try different settings step-by-step. Though Cloudflare settings affect instantly your production environment, my experience has shown it’s still risk-free. Cloudflare features are tested by millions of websites and it’s safe to apply features on production. Please look at my Cloudflare Setup Guide for further details. Also, be aware that when applying Cloudflare WAF you may start getting 403 responses on your administration interface. In that case you may need to switch off WAF rules one by one. In case you have an online store you should make sure that callback hooks still remain working and not cached by Cloudflare. Again you can use Page Rules to exclude any endpoints from the cache. Regardless of the minimum risk you should execute your tests when the traffic is minimum on your website. The latter applies only when changing Cloudflare settings. And finally, you can use GTMetrix to measure your staging configuration and whether the result is any better. Also please note that Pro plan for Cloudflare is strongly suggested as the minimum.

      Best regards,
      Janz

Leave Comment

Your email address will not be published. Required fields are marked *