Best LiteSpeed cache plugin settings

Best LiteSpeed cache plugin settings

In this guide, we’re configuring LiteSpeed Cache for best optimization results. 

The “best” settings are different for each site and you should really go through each one yourself and test your results. What that said, this guide is intended to be more of a baseline.

There’s no reason to use any other cache plugin since LiteSpeed Cache has excellent reviews, extensive settings, and uses faster server-level caching. It’s definitely the best free cache plugin.

We’ll also be setting up QUIC.cloud’s CDN which is built for LiteSpeed. But just a heads up, the free plan only uses 6 PoPs while the paid (standard) plan uses all 70 PoPs with DDoS protection.

If you’re not using LiteSpeed hosting yet, I like NameHero’s Turbo Cloud plan which has more CPU/RAM than similar hosts like Hostinger/A2 with NVMe storage. $8/month gets you 3 CPU + 3GB RAM with NVMe SSDs, but their data centers are only in US/NE. Here’s a list of LiteSpeed hosts I put together. You also have JohnnyVPS and Scala who has a perfect 5/5 TrustPilot rating.

ON – enable.

OFF – disable.

TEST / DEPENDS – test your results, or it depends on other settings.

CONSUME RESOURCES –  indicates the setting may consume more server resources which can lead to 5xx errors + CPU overages on shared hosting and less powerful servers.

1. Dashboard

LiteSpeed’s Dashboard shows the status of optimized images, CDN usage, CSS, etc. Measuring your PageSpeed scores here is more accurate than third-party browser tools such as GTmetrix.

2. General

Automatically Upgrade – ON – likely maintained well enough to do this.

Domain Key – request a domain key and add it here, then link to QUIC.cloud.

Guest Mode – ON – improves load time for first time visitors by saving time reading cookies, looking for cache varies, and processing ESI. You can read more about Guest Mode + Guest Optimization here, but it has great feedback in Facebook Groups. This setting can consume resources if crawling is on and doesn’t work with Cloudflare APO.

Guest Optimization – ON – aggressive page and image optimization for first time visits.

Server IP – click “Check my public IP from DoAPI.us” and copy/paste your server IP here.

Notifications – ON – turn on if you want notifications from LiteSpeed (i.e. new releases).

3. Cache

Cache

Enable Cache – On – test your site in uptrends.com and look for x-litespeed-cache hit.

Cache Logged-in Users – Off – only enable if you run a membership website or similar and have users logging in that need their own cache, otherwise it consumes resources.

Cache Commenters – Off – creates a separate cache for people who leave a comment which is still pending, but also consumes resources if your blog gets lots of comments.

Cache Rest API – On – used for many themes, plugins, and the WordPress Block Editor.

Cache Login Page – On – saves server resources since the login page is a common target. Don’t change the login URL since LiteSpeed + QUIC.cloud optimize the default login page.

Cache favicon.ico – On – caches favicon (the small logo image shown in the browser tab).

Cache PHP Resources – On – caches static PHP files (i.e. CSS + JS) loaded by your theme. Only disable if you have dynamic CSS + JavaScript loaded in PHP, which you likely don’t.

Cache Mobile – Depends – only enable if you serve different content on mobile/desktop, or use AMP, CCSS, UCSS, or Guest Mode and Guest Optimization (consumes resources). Since I recommend Guest Mode + Guest Optimization be turned on, this would also be on.

Cache URIs – not necessary for most websites since the “cache logged-in users” setting handles private cached URIs, and no pages on your site generally need to be force cached.

Drop Query String – marketing campaigns and tracking URLs often contain query strings where caching is ignored. The default list is usually fine, but if you have others, add them.

TTL

Cache TTL – default settings are usually fine. Cache TTL is the amount of time LiteSpeed Cache keeps a cached file. Once it expires, it will create a new one. A shorter TTL is only needed if you update your site frequency and want to guarantee visitors will see the new cached version, but this will also consume more resources. A long TTL will save resources, but the cache won’t be refreshed as frequently, so visitors might not see the new content.

Purge

Purge All On Upgrade – On – purges cache when WordPress core/themes/plugins are upgraded to make sure your site displays properly. LiteSpeed says to leave this on as well.

Auto Purge Rules For Publish/Update – default settings are OK. Whenever you publish a post, your blogroll and other content may need to update, so they should also be purged.

Serve Stale – Off – when turned on, the most recently purged (stale) copy of the page is served if the new cached version isn’t generated yet (enabling this consumes resources).

Scheduled Purge URLs – no need to add URLs here unless you need pages purged at specific time (during low traffic), in which case you would also set scheduled purge time.

Purge All Hooks – default settings are fine. When specific hooks are run, it will purge all. LiteSpeed says adding comment_post may be good to purge all when a comment is made.


Excludes

Nothing to do here for most sites. You’re already controlling the cache in other LiteSpeed Cache settings, so there’s usually no reason to exclude things from the cache unless you have a reason.

ESI

Enable ESI – Off – controls how specific elements on your dynamic pages are cached, whether it be publicly, privately, with a custom TTL, etc. Complicates things (LiteSpeed says it’s easier for a server to return full pages without messing with this). If ESI is off, there’s no need to change settings for admin bar, comment form, Nonces, or Vary Group. I’ve never used the ESI feature so I’ll be the one to admit I shouldn’t be giving advice on it.

Object

Object Cache – On – caches your database. I prefer Redis over memcached, but which one’s ‘best’ is debatable. To pass the connection test, enable Redis or memcached in your hosting account (only one). In cPanel, this is in Select PHP Version → Extensions, then enable the Redis or memcached extension. Save changes and recheck the connection test.

Method – Redis if that’s the extension you enabled in your host, otherwise memcached.

Host – leave as localhost.

Port – leave as the default port.

Default Object Cache Lifetime – 360s is fine.

Username/Password – leave as-is (not needed).

Redis Database ID – leave unless you use Redis and need a different ID.

Global Groups – leave as-is (groups that should be cached at network level).

Do Not Cache Groups – leave unless you want to add groups excluded in object cache.

Persistent Connection – On – connection is kept alive and can make Memcached faster.

Cache WP-Admin – Depends – caching the admin can speed it up but also risks you seeing outdated data. You can enable it if your admin is slow, otherwise leave this off.

Store Transients – On – recommended by LiteSpeed to get server status notifications.

You will need to activate Redis or memcached in your hosting account to pass the connection test

Browser

Browser Cache – On – not sure why this isn’t enabled by default.

Browser Cache TTL – 31557600 – this is 1 year which is recommended by Google to “serve static assets with an efficient cache policy” and tells browsers how long cache is stored. WooCommerce/dynamic websites probably want to set this to 43800 (1 month).


Advanced

Login Cookie – leave as-is (only needed if you have multiple WordPress installs and need the cache to distinguish who is logged into which WordPress site, not used for a multisite).

Improve HTTP/HTTPS Compatibility – Off – only enable if you’re using both HTTP and HTTPS and are noticing issues with the cache. You can also try forcing SSL to solve issues.

Instant Click – On – similar to the Flying Pages plugin and WP Rocket’s link preloading. When users hover over a link, the page will download in the background so by the time they click it, the page will appear to load instantly (enabling this can consume resources).


4. CDN

QUIC.cloud CDN – On – I recommend QUIC.cloud (even over Cloudflare in most cases) since it uses HTML caching which is similar to Cloudflare APO. It also has several other features listed below. You will first need to get a domain key in the LSC General settings.

Use CDN Mapping – Off – QUIC.cloud’s CDN and Cloudflare don’t use CDN mapping, so this would usually be off. The only time you should use it is if you’re using a CDN that uses a CDN URL like BunnyCDN. In this case, add the CDN URL and select the files to be served.

HTML Attribute To Replace – leave as-is since the CDN mapping setting is turned off.

Original URLs – leave as-is unless it’s a multisite with different domains + subdomains.

Included Directories – just the wp-content and wp-includes directories should be fine.

Exclude Path – leave as-is unless you want to exclude specific directories from above.

Cloudflare API – only needed if you’re using Cloudflare’s CDN instead of QUIC.cloud CDN.


Setting Up QUIC.Cloud CDN

Ryan from NameHero already made a video on setting up QUIC.cloud with LiteSpeed, but I listed the steps below as well. There’s a lot of good stuff there and I recommend watching it.

You must have a domain key in the “General” settings to use QUIC.cloud.

QUIC.cloud PoPs

Step 1: Enable QUIC.cloud CDN in the LSC CDN settings (leave CDN Mapping off).


Step 2: In your LiteSpeed Cache General settings, click “link to QUIC.cloud.”


Step 3: Go to your QUIC dashboard, sign up, and your domain will be added automatically.


Step 4: Click your domain and go to CDN → Enable CDN.


Step 5: Choose a method for connecting the CDN: QUIC.cloud DNS, Cloudflare DNS, or CNAME (external DNS). QUIC.cloud + Cloudflare’s DNS are both fast, but QUIC.cloud DNS is the easiest.

QUIC.cloud DNS: the easiest method is using QUIC.cloud’s DNS but this means you’ll be using AWS’s Route53 which is usually slower than Cloudflare’s DNS. They will copy your DNS records, then click “enable and add records” and they will assign you 2 nameservers. Login to your domain registrar and change nameservers to QUIC’s. Wait for QUIC to detect the change (i.e. 30 min.) and refresh the page. If successful, you’ll see “Using DNS” in QUIC.

Cloudflare: LiteSpeed has a video tutorial on this. You will change your CNAME in Cloudflare to the one provided by QUIC.cloud. To do this, go to Cloudflare’s DNS settings and delete the A records for both your www and non-www domain. Next, create CNAME records for www and non-www domains. Make sure you use “DNS Only.” If you have Mail or MX records which use your root domain, you will need to create a subdomain and point the MX record to it. If you have issues, it may be caused by redirects in your .htaccess file.

CNAME: copy the address from QUIC.cloud and login to your hosting panel (i.e. cPanel). Go to Zone Editor → Manage and find your domain (www.tomdupuisdemo.com). Click “edit” and change the record (tomdupuisdemo.com) to the URL from QUIC.cloud. Note this only works if your site is using the www version in your WordPress General settings.

QUIC.cloud DNS: you’re assigned 2 nameservers which you’ll change in your domain registrarCloudflare DNS: delete A records for www/non-www in Cloudflare and replace with CNAME provided by QUIC.cloudCNAME: paste QUIC.cloud’s CNAME record in cPanel → Zone Editor

Step 6: Verify QUIC.cloud’s CDN is working. You should see a confirmation message in your QUIC.cloud dashboard (i.e. Using DNS when using QUIC.cloud’s DNS). Eventually, you’ll see traffic is served through QUIC.cloud in the Analytics settings. You can also do an HTTP/3 Test.

Step 7: Configure the “CDN Config” settings in QUIC.cloud. Here are a few tips:

Enable static cache (unless you’re using another CDN to cache static files)

Enable QUIC backend which lets QUIC connect to your server via QUIC and HTTP/3.

The Standard Plan gives you access to security and anti DDoS features with reCAPTCHA and WP Brute Force Defense, restricting XML-RPC, and includes settings for WordPress.

Step 8 (Optional): QUIC.cloud’s IPs are automatically whitelisted as of v.1.7.13, so you shouldn’t need to do anything. But I included the link to their IPs in case you need them.

Step 9: Use the standard plan, not the free plan! Even if you don’t buy credits, you still get a certain amount of free credits (which depend on whether you’re using LiteSpeed Enterprise). The free plan only uses 6 PoPs without DDoS protection, while the standard plan uses all 70 PoPs with more features. Their credit-based system is a little confusing but it’s pretty much the same regional-based pricing as BunnyCDN. Credits are also needed for UCSS, CCSS, and LQIP.

QUIC.cloud free vs standard planActivate the standard plan and select your regions

5. Image Optimization

Configure the image optimization settings, then send an optimization request.

Auto Request Cron – On – sends a request to optimize newly uploaded images.

Auto Pull Cron – On – if the previous setting is turned on, this should be on too.

Optimize Original Images – On – see LiteSpeed’s example, but likely turn this on.

Remove Original Backups – Off – don’t remove unless you’re happy with the quality.

Optimize Losslessly – On – I prefer lossless compression but you can try this yourself.

Preserve EXIF/XMP Data – Off – removing EXIF data helps reduce your image sizes.

Create WebP Versions – On – create WebP images to serve them in next-gen formats.

Image WebP Replacement – On – enable this if you have the previous option enabled.

WebP Attribute To Replace – specify the element attributes to be replaced by WebP.

WebP For Extra srcset – On – makes sure images in custom code are served as WebP.

WordPress Image Quality Control – 85 – PSI tests images at 85% so that’s what I use.


6. Page Optimization

CSS Settings

CSS Minify – On – removes unnecessary characters from CSS.

CSS Combine – Test – Johnny makes some good arguments on why you shouldn’t combine especially if you have large CSS files. However, this is needed for UCSS to work. This is something that really depends on your website, so be sure to test your own results.

Generate UCSS – Off – only use if CSS combine is turned on. UCSS helps remove unused CSS, but heavy CSS is often from themes/plugins which you can measure in the Chrome Dev Tools coverage report (see screenshot). If this is on, “cache mobile” should also be on. UCSS relies on QUIC.cloud (as well as CCSS) so you’ll want to be using QUIC if those are on.

UCSS Inline – Off – this should always be off. Even if UCSS is enabled, it’s better to load it in a separate file vs. inline (explained by Vikas). This way, the separate file can be cached and doesn’t increase HTML size. Turning this on might give you better PageSpeed Insights scores, but it’s slower for actual visitors. Same reason remove unused CSS is faster in FlyingPress (which loads it in a separate file) compared to WP Rocket which loads it inline.

CSS Combine External and Inline – Off – turn on if “combine CSS” is also on. This also combines external/inline CSS files which can often prevent your website from breaking.

Load CSS Asynchronously – Test – you’ll likely get FOUC or layout shift issues if this is enabled, but this is something I would definitely test and see how it impacts your speed.

CCSS Per URL – Off – disable if previous optionis off, especially if using a page builder.

Inline CSS Async Lib – Off – CSS will be render-blocking, but you’ll avoid FOUC issues.

Font Display Optimization – default. Setting this to Swap can also cause FOUC issues. But if you see “ensure text remains visible during webfont load” in PSI, you can try Swap.


JS Settings

JS Minify – On – strips unnecessary characters from JavaScript.

JS Combine – Off – don’t combine with HTTP/2 or large JS files.

JS Combine External and Inline – Off – only enable if JS combine is enabled.

Load JS Deferred – Test – delay will probably give you the best results, deferred is also good but can break your website, off is safest. If the defer option breaks your site, exclude problematic files under “JS Deferred Excludes” in the Tuning settings. Test them yourself.


HTML Settings

HTML Minify – On – strips unnecessary characters from HTML.

DNS Prefetch – open your third-party code report in PSI and look at all third-party domains loading on your site. Ignore CDN URLs + fonts.gstatic.com since they should use preconnect instead of prefetch. Next, eliminate all third-party code that is being delayed. The only domains you should prefetch are the ones left after that. Or you can see this list.

DNS Prefetch Control – On – leave it on, but nothing to do if you added them manually.

HTML Lazy Load Selectors – lazy loads HTML (#comments and #footer are common). View this FlyingPress documentation which has a video tutorial and is the same process for LiteSpeed Cache. View your site → right click any element you want to lazy load → inspect → right click highlighted code → copy → copy selector → paste it into this field.

Remove Query Strings – Off – somewhat outdated and shouldn’t impact load times.

Load Google Fonts Asynchronously – Off – test carefully and view your GTmetrix Waterfall “fonts” tab to see the difference in your font load times. I like to keep it off.

Remove Google Fonts – Off – only use if you’re hosting fonts locally and want to make sure any third-party fonts aren’t being loaded on your website, which they shouldn’t be.

Remove WordPress Emoji – On – emojis aren’t good for load times, so turn this on.

Remove Noscript Tags – Off – some people are still using old browsers. Keeping tags ensures better compatibility to make sure your website’s JavaScript is loaded correctly.


Media Settings

Lazy Load Images – On – you can also add a fade-in effect for smoother scrolling.

Basic Image Placeholder – use an image placeholder while the images are loading.

Responsive Placeholder – Depends – on if using basic image placeholder (reduces CLS).

Responsive Placeholder SVG – specify the SVG to use as the responsive placeholder.

Responsive Placeholder Color – default gray color LiteSpeed Cache uses should be fine.

LQIP Cloud Generator – On – a lower quality image (which is generated by QUIC.cloud) will be used as the placeholder before the higher quality image is loaded. Test it yourself.

LQIP Quality – if the previous setting is enabled, this determines the lower quality image.

LQIP Minimum Dimensions – 150×150 pixels is fine. This is only for when LQIP cloud generator is turned on, and LQIP will only be used when images are larger than this size.

Generate LQIP In Background – On – LiteSpeed says turning it off slows down page load.

Lazy Load Iframes – On – lazy loading videos, maps, and other iframes improves speed.

Add Missing Sizes – On – adds missing image dimensions to set explicit widths + heights.


Media Excludes

Exclude all above the fold images from lazy load (logo, sidebar images, background images, etc). You can exclude the images by URL, class name, URI, as well as exclude images from LQIP.


Localization

Gravatar Cache – On – great when you have lots of comments with Gravatars.

Gravatar Cache Cron – On – you want it enabled if the previous setting is enabled.

Gravatar Cache TTL – the default setting of 604800 seconds (1 week) should be fine.

Localize Resources – On – great feature to localize external JS files. Add them below.

Localization Files – view third-party JavaScript loading on your site (you can do this in Chrome Dev Tools, PageSpeed Insights, etc). Then add their JavaScript file. See the list below, but make sure you test them carefully to make sure everything is working correctly. You may also want to go through support forums to see common issues with localization.

 ### Popular scripts ### https://platform.twitter.com/widgets.js https://connect.facebook.net/en_US/fbevents.js https://www.google-analytics.com/analytics.js https://www.googletagmanager.com/gtm.js https://www.googletagmanager.com/gtag/js https://www.googletagservices.com/tag/js/gpt.js https://www.googleoptimize.com/optimize.js https://www.google.com/recaptcha/api.js https://maps.google.com/maps/api/js https://maps.googleapis.com/maps/api/js https://pagead2.googlesyndication.com/pagead/js https://platform.twitter.com/widgets.js https://ajax.cloudflare.com/ https://cdnjs.cloudflare.com/ https://ajax.googleapis.com/ajax/ https://netdna.bootstrapcdn.com/ https://stackpath.bootstrapcdn.com/ https://code.jquery.com/ 

Tuning
Most settings are if you want to exclude specific things from being optimized (CSS, JS, URLs, deferred JS, Guest Mode JS, and roles). You usually only need to do this if a specific setting breaks your site. For example, if you minify or combine CSS/JS and it breaks your site, find the problematic file (in your source code), then add them. Same concept for most other settings.

7. Database

In the Manage tab, you probably want to delete everything except post revisions and auto drafts, which are backups of posts that you may need in the future. You can also optimize tables.

DB Optimization Settings

Revisions Max Number – 10 gives me some backups and doesn’t add too much bloat.

Revisions Max Age – 0 makes sense to me (they will never be deleted). Sometimes I don’t update a post for a very long time, so automatically deleting the backups isn’t a good idea.


8. Crawler

This crawls your site for pages with expired cache and refreshes them. It consumes resources which is why it’s controlled at a server level and usually not allowed by most hosts, especially shared hosting (it’s usually only if you manage your own server). So, you usually don’t need to do anything. If you do manage your own server, you’ll want to enable the crawler and see WP Johnny’s instructions (in summary, he recommends enabling the crawler in the General settings, submitting your sitemap in Sitemap settings, then leaving all other settings as default).


9. Toolbox

Most Toolbox settings are explanatory (purging, import/export, edit .htaccess, reports, debug, logs, beta test, etc). So I’ll just cover the heartbeat settings which control WordPress heartbeat.

Heartbeat

Frontend Heartbeat Control – On – control heartbeat in the frontend.

Frontend Heartbeat TTL – 0 – you can usually disable it here, but test it.

Backend Heartbeat Control – On – control heartbeat in the backend.

Backend Heartbeat TTL – 0 – you can usually disable it here, but test it.

Editor Heartbeat – On – controls heartbeat in the post editor.

Editor Heartbeat TTL – 120 – you probably want things like autosaves, but increase it.

Post a Comment

أحدث أقدم

View All