LiteSpeed Cache Settings

Easy Step-by-Step Setup Guide

Last updated on October 18, 2020 by Janz Nordman

Disclosure: I'm an affiliate and may earn a commission. Read more...

Aligned with version 3.5.x
General
Cache
CDN
Image Optimization
Page Optimization
Database

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

Important

Many of the optimization features can be used on 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.

Clarification

Are 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

[1] General Settings


Automatically Upgrade OFF

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.

Domain Key

When you would like to use QUIC.cloud CDN or image optimization then you need to generate Domain Key to connect to the online services. Click on the Request Domain Key button and wait for approval. Domain key will be automatically sent to your WordPress after some time.

NB! Creating QUIC.cloud account is not mandatory.

Recommendation

I do recommend to use QUIC.cloud for image optimization. QUIC.cloud comes with an optimization quota of 1000 images month for free. When you have a small website then this is enough for you. After exceeding this limit it’s up to you to either wait till next month or top-up more quota.

Notifications OFF

I suppose you have other channels to get all the information you need. Let’s be honest notifications are annoying.

Cache

[1] Cache


Enable Cache Enable

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.

Cache Mobile OFF

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.

Recommendation

For 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.

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/$

Note

Note 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.

[2] TTL


Recommendation

For 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.

[3] Purge


Purge All On Upgrade ON

Turn this option ON to have LiteSpeed cache assets renewed automatically, whenever a new version is released.

Auto Purge Rules for Publish/Update All pages

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.

Serve Stale ON

This is an option that benefits very busy sites but has less of an impact on low traffic sites. When a stale page with some reason is not acceptable for your requirements then disable this option. On heavy traffic circumstances, this option keeps servers very happy 🙂

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

Note

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

Scheduled Purge Time

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

10:00 PM

[4] Excludes


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

Note

You 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

Note

You 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

Note

You 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

Note

You 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

Note

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

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

Note

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

Do Not Cache Roles Administrator

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

[5] ESI Coming Soon


Stay tuned!

[6] Object


Note

Please ask your hosting provider about the availability of different object cache solutions for your hosting service before using this feature.

Object Cache ON

An object cache stores the results of frequent database queries in a way that makes them faster to retrieve and eliminates the need for repeated access to the database. Object caching greatly reduces the time it takes to retrieve the same query results.

Note

When you use the page cache, then object cache is most efficient only when WordPress builds the page for the first time. In the next request, the server hits the page cache without needing to use the object cache. When you purge the page cache, WordPress uses object cache again to rebuild the same page with the latest content.

Method Memcached

You can use either Memcached or Redis cache for your website. For simplicity, I recommend using Memcached, while Redis offers a rich set of features that make it effective for a wide range of use cases.

Note

A2 Hosting provides a Memcached installed for most of their Managed and Turbo plans only.

Host localhost

Usually, object cache is available on localhost hostname or 127.0.0.1 IP address. Please ask your hosting provider to give you the correct hostname or IP address when you are unable to connect successfully.

Note for Advanced Users

When using Memcached then the host parameter may also specify the path of a Unix socket file path e.g. /path/to/memcached.sock. Various tests indicate that Unix sockets maybe 33% faster than TCP sockets.

Port 0

Use value 0 for default ports. The default port for Memcached is 11211 and the default port for Redis is 6379. Please ask your hosting provider to provide the correct port when you are unable to connect successfully.

Default Object Lifetime 360

Please use the default value.

Persistent Connection ON

Use keep-alive connections to speed up cache operations.

Cache Wp-Admin OFF

Please keep this feature disabled. Otherwise, you may encounter expired data when using administration UI.

Store Transients ON

Enable this feature to receive server notices when Cache Wp-Admin is disabled.

[7] Browser


Browser Cache ON

Turn this option ON for static files. Extensions like .bmp, .jpeg, .pdf, .ps, .ttf, .jpg, .svg, .webp, .css, .js, .woff, .gif, .png, .woff2, … are considered all as static files. Those files unlikely change often that’s why they are “static”.

NB! This setting will edit the .htaccess file.

Browser Cache TTL

Leave default value unless you have good reasons to use different TTL values.

Recommendation for Advanced Users

When using CDN service then this value can be set to 604800 (one week). At the same time make sure to set CDN TTL to 31557600 (one year). Usually, CDN services have an option to purge cache on request.

[7] Advanced Coming Soon


Stay tuned!

CDN

[1] CDN Settings


QUIC.cloud CDN OFF

Assuming you are using Cloudflare CDN service instead.

Cloudflare API ON

First, you need to get your Global API Key from Cloudflare. Otherwise please fill in your e-mail address, API key, and domain to activate Cloudflare API. When integration is activated you should see corresponding options on Manage page.

[2] Manage


Cloudflare

When you have activated your Cloudflare API successfully you should be able to control Development Mode and Cloudflare Cache from your WordPress administration interface.

Hint

When you would like to purge only a particular resource from Cloudflare cache then navigate to Caching > Configuration > Custom Purge on your Cloudflare UI.

Image Optimization Coming Soon

Stay tuned!

LiteSpeed Cache Settings – Page Optimization Advanced

[1] CSS Settings


CSS Minify ON

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.

CSS Combine ON

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 Settings > CSS Excludes option when any CSS file needs to be excluded from the combined file.

Unique CSS File ON

Enabling this will get one combined CSS file for each URI. This is one of the crucial settings in performance tuning. Now you can see how much unused CSS you have per page. This is useful when you want to refine your CSS and remove the unused CSS per page.

NB! CSS Combine must be set to ON.

CSS HTTP/2 Push ON

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

NB! Connections must use SSL.

Load CSS Asynchronously OFF

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.

Font Display Optimization Swap

This setting tells browsers how fonts should be displayed while being downloaded. Swap means that the font will be drawn immediately on the page with a fallback font. There is zero block time, meaning that the page will not wait for the font to load. However, as soon as the required font is available, the browser will swap out the fallback text in favor of the new font.

Recommendation

When using this option it’s also recommended to preload font files to avoid swap effect or to minimize the time of displaying fallback font.

[2] JS Settings


JS Minify ON

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

JS Combine ON

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.

JS HTTP/2 Push ON

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

NB! Connections must use SSL.

Load JS Deferred ON

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.

Note

When using Cloudflare’s Rocket Loader feature then this functionality is already turned on for you, although it may behave differently.

Load Inline JS Deprecated since version 3.5 After DOM Ready

Load inline javascript after DOM is fully loaded. You can even try the Deferred option if it works for you.

Note

When using Cloudflare’s Rocket Loader feature then this functionality is already turned on for you, although it may behave differently.

Exclude JQuery Deprecated since version 3.5 ON

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

[3] Optimization Settings


CSS/JS Cache TTL

Keep default value.

Advanced Recommendation

When using CDN service then this value can be set to 604800 (one week). At the same time make sure to set CDN TTL to 31557600 (one year). Usually, CDN services have an option to purge cache on request.

HTML Minify ON

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

Inline CSS Minify Deprecated since version 3.5 ON

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

NB! HTML Minify must be enabled.

Inline JS Minify ON

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

NB! HTML Minify must be enabled.

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

DNS Prefetch Control Coming Soon

Remove Comments ON

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.

Remove Query Strings ON

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.

Load Google Fonts Asynchronously Coming Soon

Remove Google Fonts Coming Soon

Remove WordPress Emoji ON

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.

Remove Noscript Tag OFF

Keep this setting OFF for now 🙂

[4] Media Settings


Lazy Load Images ON

Load images only when they enter the viewport. This can improve page loading time and decreases server load. This also enhances user experience and reduces bandwidth traffic on mobile devices.

Basic Image Placeholder

Leave empty to use default gray image placeholder. You can use your own base64 encoded image, but believe me, default option does the job very well 🙂

Responsive Placeholder ON

This option can help to reduce layout reshuffle when images are loaded. I do recommend to set this ON.

Responsive Placeholder SVG

Use default one 🙂

Lazy Load Iframes OFF

When you don’t have iframes on your webpage keep this setting OFF. Otherwise, turn this ON to reduce initial HTTP requests.

Inline Lazy Load Images Library ON

This can improve your webpage loading speed and user experience.

NB! This setting is closely related with Load Inline JS.

[5] Media Excludes


Here you can configure all the exceptions for media assets when you don’t want something lazy loaded.

[6] Localization Settings


Gravatar Cache ON

Activate this option when your website gets a lot of comments and Avatars are enabled on your website.

NB! Check on Settings > Discussions > Avatar Display whether you have Avatars enabled before enabling this setting.

Gravatar Cache TTL 604800

You can control how long Avatars will be cached by the browser. Use the default value (1 week).

Localize Resources ON

Sometimes you may want to localize external JavaScript resources to apply different cache policies. You can enter the domain names of external resources that you want to localize. Fortunately, you have a large list of domain names already prepopulated for you. Just remove domain names you do not use on your website.

1. line: https://www.googletagmanager.com/gtm.js
2. line: https://www.google-analytics.com/analytics.js

NB! Only HTTPS domain URLs can be entered.

Warning

Referencing the JavaScript file from Google’s servers ensures that you get access to new features and product updates as they become available, giving you the most accurate data in your reports. Though localization of scripts may speed up your webpage a bit, localizing Google scripts is not the recommended practice.

[7] Tuning Settings Advanced


Combined CSS Priority Deprecated since version 3.5 OFF

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.

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

Note

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

Combined JS Priority Deprecated since version 3.5 OFF

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.

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

Note

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

Database

[1] Manage


Database Optimizer

You can regularly keep an eye on this page and eliminate red badges whenever you feel necessary. Those activities should be safe and risk-free for your system.

Recommendation

Instead of regularly executing Clean all post revisions you should set Revisions Max Number different from zero in the next section.

Database Table Engine Converter Coming Soon

[2] DB Optimization Settings


Revisions Max Number

It’s up to you to find optimal revision count per post what works for you. I usually keep this number around 5.

Revisions Max Age

Recommended value is 30 days.

NB! Be aware that after defined days post revisions will be deleted.

[Next Steps] Quick Website Setup

Thanks for Reading and Good Luck on Your Journey! Need Some Help or Would Like to Ask Something about Current Content? Please Add a Comment 🙂

Cloudflare Setup Guide

Cloudflare Setup

How to install Cloudflare on your website? Read my step-by-step guide to get your website faster with Cloudflare.
Read More
A2 Hosting Setup Guide

A2 Hosting Setup

This article provides information you need for setting up a website and domain on an A2 Hosting server.
Read More

8 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

  3. Janz Nordman

    Michal W.

    Hi, It’s a really great & well-furnished article. Also just want to tell you that after installing litespeed cache plugin, the Google page speed test shows some issues generated by litespeed, which are in ”eliminate render blocking resources” and ”remove unused css” categories. Could you please advise how to solve it to speed up my website. Thanks!

    • Janz Nordman

      Hi Michal,

      great that you use the Google Page Speed tool to measure your website performance. Please note that JavaScript is considered as “parser blocking resource” hence you have to move parsing of JavaScript code as far as possible. Please use “Load JS Deferred” and “Load Inline JS” to eliminate the first issue. The second issue is not related to LiteSpeed cache at all and needs manual intervention. Please dequeue all unused stylesheet files directly in the code or make sure that styles are loaded only when related components are used. Unfortunately, this requires programming skills. As a bombshell, on a typical WordPress website, 80-90% of styles are unused. Good luck!

  4. Janz Nordman

    Joel

    Thanks so so much for this but Please update this as Litespeed has had an update. Thanks!

    • Janz Nordman

      Hi Joel,

      Somebody from the development side messed up version 3.5. LiteSpeed Cache version 3.5.0.2 is a rollback to the features that were available in version 3.4. Hence, please feel free to use all the settings described on this page and you’ll be fine.

      Best regards,
      Janz

Leave Comment

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