When buying products or services on our site, we often receive affiliate commissions that support our efforts. Learn More

Optimal LiteSpeed Cache Settings with CloudFlare CDN

Lightspeed cache + Cloudflare + Railgun

A caching plugin in a necessity for every WordPress website.  It helps with speeding up page load time promoting faster content delivery.  And if you’re hosting your site on a LiteSpeed web server, then LiteSpeed Cache is the best option.

LiteSpeed cache (LSCache) was made specifically for use with LiteSpeed web servers.  There are exclusive features only available when using with LiteSpeed.

Setup is easy and there’s also an option to directly integrate Cloudflare CDN for even more throttle.  A lot of LSCache’s default configurations are fine out of the box but you can further optimize if for speed with some tweaks.

LITESPEED CACHE SETUP GUIDE WITH CDN

LSCache is free to use.  However, the caching function won’t work on Apache or Nginx – a LightSpeed web server is a requirement.  To unlock its full potential, you have to be hosting your site with a web host using LiteSpeed.

NameHero is the best hosting option if you want to use LSCache – their business model is focused on speed.  You can check their trustpilot and sitejabber reviews – they speak for themselves.

If your site is not running on a LiteSpeed web server, WP Fastest Cache is a good freemium caching plugin while WP Rocket is the better premium option.

 

 

 

LITESPEED CACHE FEATURES

Here is a list of general and exclusive features of LiteSpeed Cache.  The general features will work with any web servers while a LiteSpeed web server is required for the exclusive options.

GENERAL FEATURES

There are many general features that still work to reduce HTTP requests even if you’re not on a LiteSpeed web server.  Here are some notable ones; some that may not be included with other free caching plugins.

    • QUIC.cloud CDN Cache
    • Object and Browser Cache
    • Image Optimization (Lossless and Lossy)
    • Combine CSS/JS & Minify CSS, JS, HTML
    • Auto generate Critical CSS
    • Lazyload images and iframes
    • CDN support including Cloudflare API
    • Asynchronously load CSS/JS
    • Database Cleaner and Optimizer
    • PageSpeed score optimization
    • OPcode Cache
    • CSS HTTP/2 push
    • DNS Prefetch
    • Multi Site support
    • WebP image format support

LITESPEED WEB SERVER EXCLUSIVE FEATURES

These features are only available when using LiteSpeed cache plugin on a LiteSpeed Webserver.  There’s more to this list that can be found on their official plugin page.

    • Auto page caching
    • Event driven auto purge of pages
    • Cache private pages for logged-in users
    • WordPress REST API calls caching
    • Separate caching of desktop and mobile views
    • Purge scheduling for specific URLs
    • WooCommerce and bbPress support
    • Exclude pages from cache
    • Cache crawler
    • HTTP/2 & QUIC support
    • ESI support

 

LITESPEED VS NGINX VS APACHE BENCHMARKS

LiteSpeed with LSCache is better at handling requests per second when compared to Nginx with FastCGI Cache and Apache with W3 Total Cache.  In fact, it is more than 10x better at handling requests per second than Apache.

litespeed vs nginx vs apache
source: openlitespeed

LSCache is the best caching plugin when using it with a LiteSpeed web server.  When paired together, it’s performance surpasses that of paid cache plugins like WP Rocket.

caching plugin comparison
source: wordpress.org

Using LiteSpeed Cache on a LiteSpeed web server with Cloudflare’s speed settings is a good formula for speed and efficiency.  Start using LSCache with LiteSpeed’s free plan.

 

 

 

STEP 1 – INSTALL LITESPEED CACHE & CLOUDFLARE

Installing LiteSpeed Cache plugin is as easy and locating it from the plugin marketplace and clicking Install Now and Activate.

LiteSpeed Cache WordPress Plugin Install

After installing the plugin, to get it working without messing with any other options, go to:

    • Settings  >>  General Tab  >>  Toggle Enable LiteSpeed Cache to Enable
    • Navigate to Manage  >>  click Purge All

 

Installing Cloudflare is just as easy.  Linking up your Cloudflare account can be done directly from your web host’s cPanel.  Just search for Cloudflare.

Cloudflare cpanel

Create a new account or login to your existing account if you already have one.

create or login to cloudflare account from cpanel

With NameHero, they give you an option for either partial (CNAME) setup or Full Zone setup.

Choosing CNAME Setup means you’d still be using NameHero’s DNS and a Full Zone Setup means you’ll be using Cloudflare’s DNS.  CNAME setup option is only available with Cloudflare’s Business plan or via a partner host like NameHero or GreenGeeks.

Once your account is activated, locate your Cloudflare Domain Name Server (DNS) and change the DNS in your hosting account to Cloudflare’s DNS if you chose the full setup.  You will not need to change your web host’s DNS to Cloudflare’s DNS with a CNAME partial setup.

 

 

 

STEP 2 – LITESPEED CACHE BASIC SETTINGS

With LiteSpeed Cache installed, let’s start with the basic settings in tabs 1 – 4.  There isn’t too much to adjust here so it’s fairly straightforward.  The most important part is just turning on the switch.

 

[1] – GENERAL

    • Enable LiteSpeed CacheENABLE
    • Default Public Cache TTLLeave as default, 604800.
    • Default Private Cache TTLLeave as default, 1800.
    • Default Front Page TTLLeave as default, 604800.
    • Default Feed TTLLeave as default, 0.
    • Default 404 Page TTLLeave as default, 3600.
    • Default 403 Page TTLLeave as default, 3600.
    • Default 500 Page TTLLeave as default, 3600.
    • Automatically UpgradeON or OFF.  I prefer to update all plugins manually.  This auto upgrade function only works if WP-Cron is enabled (WP-Cron is enabled in WordPress by default).

LSCache General Settings

[2] – CACHE

    • Cache Logged-in UsersOFF.  Turning it ON will create a separate cached page for each logged in user.
    • Cache CommentersON.
    • Cache REST APION.
    • Cache Login PageON.
    • Cache favicon.icoON.
    • Cache PHP ResourcesON.
    • Cache MobileOFF.  Only applicable for AMP pages.  Leave OFF for mobile responsive sites.
    • List of Mobile Users AgentsLeave as default.
    • Private Cached URIs – Useful when you don’t want a URI to cache publicly.
    • Drop Query String – Can be helpful when a query string doesn’t change the content of a page.

LSCache Cache Settings

[3] – PURGE

    • Purge All On UpgradeON.
    • Auto Purge Rules For Publish/UpdateLeave as default.  Choose All Pages if you have widgets on your blog posts.
    • Scheduled Purge URLs – For scheduling time specific purge of URLs.
    • Scheduled Purge Time – Specify time for scheduling URL purge above.

LSCache purge settings

[4] – EXCLUDES

    • Force Cache URIs – Used for forcing cache of pages regardless of no-cache settings.
    • Do Not Cache URIs – Used to prevent specific pages from caching.
    • Do Not Cache Query Strings – Used to prevent certain query strings from caching.
    • Do Not Cache Categories – Used to prevent specific categories from caching.
    • Do Not Cache Tags – Used to prevent specific tags from caching.
    • Do Not Cache Cookies – Used to prevent specific cookies from caching.
    • Do Not Cache User Agents – Used to prevent certain users agents from caching.
    • Do Not Cache Roles – Used to prevent certain user roles from caching.

LSCache Exclude Settings

 

 

 

STEP 3 – LITESPEED CACHE ADVANCED SETTINGS

Moving onto the advanced settings, here you have more options to work with.  Some settings may be more suitable for some and not others, especially tabs 5 – 6.  These customizations were set with Cloudflare integration in mind so if you won’t be using Cloudflare, the settings can be different.

 

[5] – OPTIMIZE

    • CSS MinifyON.  Choose OFF if already enabled with a Cloudflare but LSCache seems to do a better job of removing white spaces.
    • CSS CombineOFF.  Turning ON can make loading of CSS not as smooth.
    • CSS HTTP/2 PushOFF.  Sends CSS to the browser before request is made but this option broke my CSS.
    • JS MinifyOFF.  It is recommended to minify JS from Cloudflare.  Minifying JS from a caching plugin can interfere with Cloudflare’s Rocket Loader.
    • JS CombineON.  Turn OFF if it breaks functions in your site after enabling.
    • JS HTTP/2 PushON.  Pushes JS to browser before request is made.  HTTP/2 is required for it to work.
    • CSS/JS Cache TTLLeave as default.
    • HTML MinifyON.  Choose OFF if already enabled with Cloudflare but LSCache seems to do a better job of removing white spaces.
      • Inline CSS MinifyON.  Turn OFF if CSS is already minified from Cloudflare.
      • Inline JS MinifyOFF.  It is recommended to minify JS from Cloudflare..
    • Load CSS AsynchronouslyON.
      • Generate Critical CSSON or OFF.  It is used to load “critical” CSS rules first so pages can load faster.  I prefer OFF because I’m not working with a big file.  However, Critical CSS can be helpful for large CSS files but should be left OFF if it breaks the CSS.
      • Generate Critical CSS in BackgroundON.
      • Separate CCSS Cache Post Types – Used when you need multiple Critical CSS files created for a single post type.
      • Separate CCSS Cache URIs –  Used for specifying URIs with different formatting for creating separate Critical CSS files.
      • Inline CSS Async LibON.
    • Load JS DeferredOFF.  This will be enabled from Cloudflare with Rocket Loader so there’s no need to do it twice.
    • Exclude JQueryON.
    • DNS Prefetch – This preloads external domains like Google Analytics and Google Fonts before a request is made to promote faster page loads for the end user.  To find the list of external domains requests are being made to, first run a speed test with WebPageTest.  After the test is done, you can find the list of external domains from the “Domains” tab.
    • Remove CommentsOFF.

LSCache Optimize Settings

[6] – TUNING

    • Combine CSS PriorityOFF.  Turn ON if you need COMBINED CSS file to load before UNCOMBINED CSS file.
    • CSS Excludes – Used to list excluded CSS files from being minified or combined.
    • Combined JS PriorityOFF.  Turn ON if you need COMBINED JS file to load before UNCOMBINED JS file.
    • JS Excludes – Used to list excluded JS files from being minified or combined.
    • Max Combined File Size – Leave as default, 1.2.
    • Remove Query StringsOFF.
    • Load Google Fonts AsynchronouslyON.  Adds a preconnect to Google for downloading Google Fonts faster.
    • Remove Google FontsOFF or ON.  I assumed this is to remove fonts that come with your theme but it doesn’t seem to do anything.
    • Critical CSS Rules – Used to set Critical CSS rules when asynchronous CSS load is enabled.
    • JS Deferred Excludes – Used when JS Deferred is enabled.  You can list JS files that you don’t want deferred.
    • Remove WordPress EmojiON.  Turn OFF if you want WordPress emojis JS file to load.
    • URI Excludes – A filter used to exclude any URLs from optimizations.
    • Role Excludes – A filter used to exclude any optimizations based on the certain user-type.

LSCache Tuning Settings

[7] – MEDIA

    • Lazy Load ImagesON.  Turning it ON will delay loading of images when not in view which can help with initial page load speed.
    • Lazy Load Image Excludes – Used to exclude lazy loading of specific images.
    • Lazy Load Image Class Name Excludes – Used to exclude lazy loading of a group of images based on their class.  I excluded image classes that I don’t want to lazy load – pretty much any images that immediately displays when a page initially loads.  I’m only lazy loading images within posts.
    • Lazy Load Image Placeholder – Used to specify a placeholder image until lazy loading finishes loading.
      • Responsive PlaceholderON.  It’ll reserve a spot for your images to load so your content doesn’t shift around.
      • Responsive Placeholder Background Color – Used to choose the color of the placeholder.
      • Generate Responsive Placeholder in BackgroundON to generate placeholder automatically.  OFF will make the placeholder generate while the user is waiting.
    • Lazy Load IframesOFF.  Turn ON if you are using iframes and want to lazy load them.
    • Inline Lazy Load Images LibraryOFF.  Turning it ON will access the JS image library inline in HTML which can reduce a HTTP request.  However, the page size can get larger because it isn’t using a separate request.
    • Optimize AutomaticallyON if you want to use LSCache to optimize your images.  Turn OFF if you’re using a separate plugin to optimize images.
      • Optimize CronON.
      • Optimize Original ImagesON.
      • Remove Original BackupsOFF.
      • Optimize WebP VersionsOFF.  Turn ON if you want to save all your PNG and JPG as WebP format.
      • Optimize LosslesslyON or OFF.  Turn ON if you prefer to preserve maximum quality when compressing your images.  Losslessly compresses only about 20% while lossy compresses about 70% (Approx figures).
      • Preserve EXIF/XMP dataOFF.  Turn ON if you need image data such as camera equipment, copyright date, GPS coordinates, comments, etc.
      • Image WebP ReplacementOFF.  Turn ON if you want to use WebP images instead of JPG or PNG for all your images.
      • WebP Attribute To Replace – Used to specify the types of images replaced with WebP.
      • WebP For Extra srcsetOFF.  Used to enable WebP for images generated outside of the WordPress environment.
    • Here is the CSS code, courtesy of litespeedtech, to make images fade-in smoothly when using Lazy Load.

    • img[data-lazyloaded]{
        opacity: 0;
      }
       
      img.litespeed-loaded{
        -webkit-transition: opacity .5s linear 0.2s;
        -moz-transition: opacity .5s linear 0.2s;
        transition: opacity .5s linear 0.2s;
        opacity: 1;
      }

LSCache Media Setting

[8] – CDN

    • Enable CDNOFF since we’ll be using Cloudflare.  Skip straight to Cloudflare API.
      • CDN Mapping – Using Cloudflare so leave as default.
      • Original URLs – Using Cloudflare so leave as default.
      • Included Directories – Using Cloudflare so leave as default.
      • Exclude Path – Using Cloudflare so leave as default.
    • Load JQuery Remotely – Using Cloudflare so leave as default.
    • Quic Cloud API – Using Cloudflare so leave as default.
    • Cloudflare APION.  Go to your Cloudflare profile dashboard to find your Cloudflare API and email address associated with your account.

Cloudflare Global API Key

LSCache CDN Settings

[9] – ESI

    • Enable ESIOFF.  Turn ON if you want to uncache the Admin Bar and Comment Form in a cached page.  This allows you to serve uncached sections within a cached page.
    • Cache Admin BarLeave as default, ON, to cache the Admin Bar.
    • Cache Comment FormLeave as default, ON, to cache the Comment Form.
    • Vary GroupLeave as default.

LSCache ESI settings

[A] – ADVANCED

    • Object CacheOFF.  Turn ON to cache database queries so when a repeat request is made, the request can be served from cache instead of re-querying from database.
    • Browser CacheON.
      • Browser Cache TTLLeave as default, 2592000.
    • Check Advanced Cache – Leave this checked unless you’re using another caching plugin at the same time for a specific purpose.  Generally, you don’t want to be using multiple caching plugins at the same time.
    • Login Cookie – Used to create a unique login cookie for handling separate LSCache plugins used by multiple sites from a virtual host.
    • Purge All HooksLeave as default.
    • Improve HTTP/HTTPS CompatibilityOFF.  When turned ON, it saves all login cookies as HTTP so it’ll be accessible for both HTTP and HTTPS connections.
    • Instant ClickOFF.  Turn ON if you want your website links to get preloaded when a user hovers over it.

LSCache Advanced Settings

[D] – DEBUG

This section isn’t required for the initial setup.  It is strictly for debugging purposes so all the settings can be left as default unless you’re addressing issues.

    • Diable All FeaturesOFF.
    • Debug LogOFF.
    • Admin IPsYour IP address.
    • Debug LevelBasic or Advanced.
    • Log File Size LimitLeave as default, 3MB.
    • HeartbeatON.
    • Log CookiesOFF.
    • Collapse Query StringsOFF.
    • Log FiltersOFF.
    • Excludes FiltersLeave as default.
    • Exclude Part FiltersLeave as default.

LSCache Debug Settings

[C] – CRAWLER

The crawler has to be enabled by your web host so this section can be left as default.  Also, turning on the crawler is not recommended if you’re on a shared plan due to extensive resource consumption.

    • DelayLeave as default, 500.
    • Run DurationLeave as default, 400.
    • Interval Between RunsLeave as default, 600.
    • Crawl IntervalLeave as default, 302400.
    • ThreadsLeave as default, 3.
    • Server Load LimitLeave as default, 1.
    • Site IP – For crawling by IP instead of domain name.
    • Role Simulation – Used to crawl as a specific logged-in user.
    • Cookie Simulation – To crawl for a specific cookie.
    • Custom Sitemap – Used to crawl your own Google XML sitemap.
    • Sitemap GenerationLeave as default.  Used to generate a sitemap to crawl.

LSCache Crawler Settings

[W] WOOCOMMERCE

    • Product Update IntervalLeave as default.
    • Use Front Page TTL for the Shop PageOFF.  Turning it ON will use the front page TTL settings from the “General” tab.
    • Privately Cache CartOFF to exclude cart from caching.

LSCache Woocommerce settings

 

 

 

STEP 4 – CLOUDFLARE SPEED SETTINGS

A Cloudflare account is required to integrate their service with LSCache.  You should have already created an account from Step 1 or you can sign up for a free account if you don’t have one yet.

 

SPEED  >  OPTIMIZATION

    • Auto Minify – Only minify the JS here since HTML and CSS were minified in LSCache.  However, you can test both to see which is faster.  Just don’t enable them from both Coudflare and LSCache – choose one.
    • BrotliON.  Brotli is similar to GZIP but does a better job of file compression.
    • Rocket LoaderON.  Rocket loader is used to defer JavaScript.  This may not work properly if JS was minified with LSCache.
    • RailgunONRailgun helps with faster delivery of non-cached web pages.  This option may or may not be available based on the web host you’re using.  I’m hosting with NameHero and they include it free with all their plans.  Otherwise, this feature is available with Cloudflare’s $200 per month Business plan.

Cloudflare Speed Optimization

SCRAPE SHIELD

    • Email Address ObfuscationON.  Prevents bots from collecting your email address to lessen unwanted email in your inbox that can consume your resources.
    • Server-side ExcludesON.  Makes your content visible only to real visitors.
    • Hotlink ProtectionON.  Hotlink Protection prevents other websites from linking files from your site.  Visitors will still be able to view and download images from your website but this ensures that spammy sites cannot use up your bandwidth by linking back to images that’s hosted on your site.

Cloudflare Scrape Shield settings

 

 

 

STEP 5 – PURGE ALL CACHE

After you’re done configuring LiteSpeed Cache and Cloudflare, purge all cache from LSCache Manage page.  Try running a speed test with Google PageSpeed Insights and see how you do.  There always more you can do to optimize your site for speed.

Here are some more tips to make your site load faster.

LSCache Purge Cache

 

 

 

SUMMARY

Your LiteSpeed Cache plugin should now be setup with Cloudflare.  If this is your first time setting up Cloudflare, it can take up to 24 hours for the DNS to activate with your web host.

If you ever need in-house help from LiteSpeed, they are very active in their community.

 

Need help from an expert?
If you still need help with optimization, Fiverr is a useful website to find help at cheap prices.  Just search for WordPress speed optimization service.

 

You May Also Like

4 Comments

  1. I have activated the LiteSpeed cache plugin that run on my website. Currently just purchased WP Rocket plugin, wondering can i use together with LiteSpeed cache plugin? If so, what should i take note of, so as not being interfere with each other?

    Thanks!

    1. WebsiteEdu says:

      Most caching plugins perform many similar functions so I wouldn’t use both at the same time. If you’re on a LiteSpeed webserver, I would use LSCache but it doesn’t hurt to run some speed tests with each one since you already acquired a license. If you do decide to use both, just be sure to disable functions in one if enabled in another.

  2. What is benefit of using cloudflare here? I am newbie.

    1. WebsiteEdu says:

      In a nutshell, it makes your site load faster and more secure. It also helps preserve bandwidth by distributing a cached version of your website from their data centers. If you’re looking to make your site faster, here is a related article.

Leave a Reply

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