Help Docs Performance Website Optimization Using the LiteSpeed Cache Plugin

Using the LiteSpeed Cache Plugin

Speed up WordPress with LiteSpeed Cache. Guide: install, config (cache, page/image/DB opt, CDN) & maximize benefits with LiteSpeed Web Server.

Welcome to Liquid Web’s guide to the LiteSpeed Cache Plugin for WordPress! This powerful tool is designed to significantly speed up your WordPress site. In this article, we’ll cover what the LiteSpeed Cache plugin is, its advantages, how to install it, and a detailed walkthrough of its configuration settings.

Introduction to LiteSpeed Cache for WordPress

The LiteSpeed Cache Plugin for WordPress, developed by LiteSpeed Technologies, is a comprehensive, all-in-one site acceleration plugin. It offers a wide array of features to optimize your WordPress site for peak performance. While it provides similar functionalities to other caching plugins like W3 Total Cache, LiteSpeed Cache is free to use and offers unique advantages, especially when your site is hosted on a server running LiteSpeed Web Server.

Key Benefits:

  • Server-Level Full-Page Cache: When used with a LiteSpeed Web Server, the plugin allows the server itself to manage the cache, leading to faster load times than traditional PHP-level caching.
  • Extensive Optimization Features: Includes minification of CSS, JavaScript, and HTML, image optimization, browser cache support, object cache (Memcached/LSMCD/Redis), and more.
  • HTTP/2 & HTTP/3 Support: Leverages modern web protocols for efficient content delivery when available on the server.
  • User-Friendly Interface: Provides both basic and advanced settings to cater to users of all skill levels.
  • Compatibility: While it performs best with LiteSpeed Web Server, many optimization features (like CDN support, image optimization, CSS/JS minification) can still provide benefits on other web servers like Apache or Nginx.

This plugin boasts a vast number of features, and this guide will help you understand and configure them effectively.

Prerequisites for object caching

For the Object Caching feature within LiteSpeed Cache to function, your server needs to have a Memcached or Redis service installed and enabled. At Liquid Web, this can typically be configured via:

  • EasyApache 4: For cPanel servers, Memcached can be installed.
  • LSMCD (LiteSpeed Memcached): A fork of Memcached developed by LiteSpeed, optimized for their products.
  • Redis: Another popular in-memory data structure store.

Please contact our support team if you need assistance enabling Memcached or Redis on your server.

Installation

You can install the LiteSpeed Cache Plugin for WordPress through two primary methods:

  1. Through the WordPress Dashboard (Recommended for most users):
    • Log in to your WordPress admin area.
    • Navigate to Plugins > Add New.
    • In the search bar, type “LiteSpeed Cache” and press Enter.
    • Locate the “LiteSpeed Cache” plugin by LiteSpeed Technologies in the search results.
    • Click Install Now and then Activate.
  2. Through WHM (For server administrators managing multiple sites on a LiteSpeed server):
    • Log in to WHM.
    • Navigate to: Home » Plugins » LiteSpeed Web Server Plugin.
    • Click on Manage Cache Installations.
    • From here, you can install and manage LiteSpeed Cache for multiple WordPress instances on your server.

Configuration

Once installed and activated, you’ll find the LiteSpeed Cache menu in the left sidebar of your WordPress dashboard. Hover over “LiteSpeed Cache” to see its various sub-menus. We’ll start with the Cache settings (previously referred to as “Settings” in older versions or general conceptual settings, now often directly under “Cache” and other specific tabs).

Upon entering the plugin’s settings pages, you might see a notice to “Show Advanced Options” or find settings categorized under tabs like Cache, CDN, Image Optimization, Page Optimization, Database, Crawler, and Toolbox. For detailed configuration, ensure you can view advanced options if such a toggle exists.

Note: The LiteSpeed Cache plugin interface and setting locations can evolve with updates. The descriptions below cover common and important settings. Always refer to the setting descriptions within the plugin for the most current information.

General settings (Often found under LiteSpeed Cache > Settings or a similar top-level tab)

These settings control the plugin’s master switch and default cache behaviors.

Enable LiteSpeed Cache

Function: Toggles the entire plugin’s caching functionality on or off. Recommendation: Set to ON to use the plugin. This is useful for temporarily disabling caching during troubleshooting (e.g., to check if an issue is caused by caching or another plugin like Cloudflare).

Default public cache TTL (Time To Live)

Function: Sets the duration (in seconds) for which publicly accessible content (e.g., blog posts, pages viewable by any visitor) will be stored in the cache. Default: 604800 seconds (7 days). Recommendation: The default is usually fine. Adjust if your content updates very frequently and needs to reflect instantly for all users, though purging is a better approach for immediate updates.

Default private cache TTL

Function: Sets the duration (in seconds) for which user-specific content will be cached. Private cache stores items unique to a logged-in user, such as shopping cart contents or personalized information. Default: 1800 seconds (30 minutes). Recommendation: Only relevant if private caching is enabled. The default is generally suitable.

Default front page TTL

Function: Sets the cache duration for your website’s front page. Default: 604800 seconds (7 days). Recommendation: If your front page updates very frequently (e.g., a news site with constantly new headlines), you might consider a lower TTL. Otherwise, the default is acceptable.

Default feed TTL

Function: Sets the cache duration for WordPress RSS feeds. Default: 0 (disabled by default) or 604800 seconds if enabled. Recommendation: If your feeds are frequently updated and accessed, caching them can be beneficial. The default of 7 days when enabled is a good starting point.

Default 404 page TTL / Default 403 page TTL / Default 500 page TTL

Function: Determine how long error pages (404 Not Found, 403 Forbidden, 500 Internal Server Error) should be cached. Default: 3600 seconds (1 hour) for 404 and 403. For 500 errors, caching might be disabled by default or set to a low TTL. Recommendation: Defaults are generally appropriate. If your site is experiencing frequent 500 errors, it’s advisable to disable caching for 500 pages (set TTL to 0) to aid in troubleshooting and prevent users from seeing cached error messages after a fix.

Automatically upgrade

Function: Toggles whether the LiteSpeed Cache plugin should update itself automatically when a new version is released. Default: Off. Recommendation: Enabling automatic updates (set to ON) ensures you receive the latest features, bug fixes, and security patches promptly. However, some users prefer to update manually after checking changelogs and performing backups.

Cache settings (LiteSpeed Cache > Cache)

This section delves into specific caching behaviors.

Cache logged-in users

Function: When enabled, content specific to logged-in users is cached privately. This can include usernames, avatars, or other dynamic information tailored to the logged-in user. Default: ON. Recommendation: Set to ON if you have user-specific content for logged-in users. Important: This requires private caching to be functional and correctly configured. Do NOT enable if your site does not differentiate content for logged-in users or if private caching is not intended/supported server-side for your setup (though with LiteSpeed server, it generally is).

Cache commenters

Function: Allows for caching of pages for users who have recently left a comment, potentially showing their pending comment information. This is a form of private caching. Default: ON. Recommendation: Generally safe to leave ON. Ensures commenters see their comments (even if pending moderation) correctly. Requires private caching.

Cache REST API

Function: Toggles caching for WordPress REST API calls. The REST API is used by themes, plugins, and external applications to interact with your site’s data. Default: ON. Recommendation: Caching REST API can improve performance for sites that heavily use it for public, non-changing data. However, be cautious.

  • When to use: Good for public data endpoints that don’t change frequently.
  • When to avoid or test carefully: If your REST API is used for e-commerce transactions, user-specific data retrieval, or critical real-time operations, indiscriminate caching could lead to stale data or malfunctions. Ensure that endpoints handling sensitive or dynamic user-specific data are either not cached or handled correctly by private caching rules.

Test thoroughly after enabling.

Cache favicon.ico

Function: Enables caching of your site’s favicon.ico file, which is the small icon displayed in browser tabs. Default: ON. Recommendation: It’s recommended to keep this ON. This option may modify your .htaccess file to add caching rules for the favicon.

Cache PHP resources

Function: Toggles caching for static resources (like CSS or JS files) that are loaded via PHP scripts. This is different from OpCode caching (which caches compiled PHP code) and focuses on the assets themselves. Default: ON. Recommendation: Generally safe to keep ON as it can improve performance by caching these resources.

Cache mobile

Function: Enables a separate cache for mobile devices. Default: OFF. Recommendation: Enable this (set to ON) only if your site serves significantly different content or uses a separate theme for mobile devices versus desktop devices. If your site uses a responsive design (where the layout adapts to screen size using CSS, but the content is the same), this should be kept OFF.

List of mobile user agents

Function: If “Cache Mobile” is enabled, this field allows you to specify a list of mobile browser user agents that should receive the mobile cached version. Default: A pre-filled list of common mobile user agents. Recommendation: The default list is usually sufficient. Modify only if you have specific needs or encounter issues with mobile detection.

Private cached URIs

Function: Allows you to specify a list of URL paths (one per line) that should always be cached privately, even if they would normally be public. Useful for pages that contain user-specific information but might not be automatically detected as such. Recommendation: Use as needed for specific pages like user dashboards or profile pages that are not automatically handled by logged-in user caching.

Drop query string

Function: Allows you to specify query strings (e.g., utm_source, gclid) that should be ignored by the caching mechanism. This means URLs with these query strings will be served the same cached page as the URL without them. Default: Often includes common marketing and tracking query strings like utm*, fbclid, gclid. Recommendation: The defaults are generally good. This helps improve cache hit rates by not creating separate cache entries for URLs differing only by tracking parameters.

Purge settings (LiteSpeed Cache > Toolbox > Purge)

Purge settings control when and how the cache is cleared.

Purge all on upgrade

Function: When enabled, the entire cache will be automatically purged whenever WordPress core, themes, or plugins are upgraded. Default: ON. Recommendation: It’s highly recommended to keep this ON to prevent compatibility issues or display errors from outdated cached content after an update.

Auto purge rules for publish/update

Function: Determines which related pages should be purged when a post is published or updated. For example, updating a post might require purging the homepage, archive pages, category pages, and tag pages where that post appears. Default: Sensible defaults are usually selected. Recommendation: Review the default selections. Typically, you want relevant archives and the front page to be purged to reflect new content.

Scheduled purge URLs

Function: Allows you to specify a list of URLs (one per line) that should be purged automatically at a scheduled time. Recommendation: Use this if you have specific pages that need regular purging but aren’t covered by other auto-purge rules. This is often less used than event-driven purging.

Scheduled purge time

Function: Sets a specific time (or times) for the “Scheduled Purge URLs” to be purged. Recommendation: Configure if you are using “Scheduled Purge URLs.” Choose a low-traffic period if possible.

Excludes settings (LiteSpeed Cache > Cache > Excludes)

Exclusion rules define content that should not be cached or specific caching behaviors for certain content.

Force cache URIs

Function: A whitelist of URL paths (one per line, partial paths allowed) that should always be cached, overriding other “do not cache” rules. Recommendation: Use with caution. Only for specific URIs you are certain should be cached despite other potential exclusion rules.

Do not cache URIs

Function: A blacklist of URL paths (one per line, partial paths allowed) that should never be cached. Recommendation: Essential for pages like checkout, cart, login, or any page with highly dynamic, user-specific, or sensitive information that should never be served from a public cache. Many e-commerce plugins will automatically add their critical pages here.

Do not cache query strings

Function: A blacklist of query strings. Any URL containing these query strings will not be cached. Recommendation: Use if specific query parameters lead to pages that should not be cached.

Do not cache categories

Function: Specify category slugs (one per line) whose archive pages should not be cached. Recommendation: Use if certain category archives are highly dynamic or problematic when cached.

Do not cache tags

Function: Specify tag slugs (one per line) whose archive pages should not be cached. Recommendation: Use if certain tag archives are highly dynamic or problematic when cached.

Do not cache cookies

Function: Specify cookie names (one per line). If a visitor has one of these cookies in their browser, they will not be served cached content. Recommendation: Useful for custom functionalities that rely on specific cookies to alter content dynamically.

Do not cache user agents

Function: Specify user agent strings (one per line, partial matches allowed). Visitors using these user agents will not be served cached content. Recommendation: Can be used for troubleshooting with specific browsers or for blocking certain bots from hitting the cache, though usually not needed.

Do not cache roles

Function: Select WordPress user roles (e.g., Administrator, Editor). Logged-in users with these roles will not be served cached content. Recommendation: Often, administrators and editors prefer to see live content when making changes. This is a useful setting for them, often enabled by default for ‘administrator’.

Page optimization settings (LiteSpeed Cache > Page Optimization)

These settings focus on optimizing the actual content of your pages, like CSS, JavaScript, and HTML files.

Caution: Minification and combination settings can sometimes cause issues with your site’s appearance or functionality. Always test your site thoroughly on different devices and browsers after enabling any of these options. It’s recommended to enable and test them one by one.

CSS settings (Page Optimization > CSS Settings)

CSS minify

Function: Removes whitespace, comments, and other unnecessary characters from CSS files to reduce their size. Default: OFF. Recommendation: Generally safe to enable (set to ON). This can improve load times and scores on performance testing tools like GTmetrix. Test your site’s appearance thoroughly after enabling.

CSS combine

Function: Merges multiple CSS files into a single file. This reduces the number of HTTP requests needed to load your page. Default: OFF. Recommendation: Can significantly improve performance, but it has a higher risk of causing display issues, especially with complex themes or many plugins. If you enable this (set to ON), test extensively. If issues arise, you may need to exclude certain CSS files from combination using the available exclusion options.

CSS HTTP/2 push

Function: For servers supporting HTTP/2 or HTTP/3, this allows the server to proactively send CSS files to the browser before the browser explicitly requests them. Default: ON. Recommendation: If your server supports HTTP/2 or HTTP/3, this is generally safe and beneficial to keep ON.

JS settings (Page Optimization > JS Settings)

JS minify

Function: Removes whitespace, comments, and condenses JavaScript files to reduce their size. Default: OFF. Recommendation: Can improve load times. Enable (set to ON) with caution and test your site thoroughly, as JavaScript is more prone to breaking with minification than CSS.

JS combine

Function: Merges multiple JavaScript files into a single file, reducing HTTP requests. Default: OFF. Recommendation: Offers significant performance benefits but also carries a high risk of breaking site functionality (e.g., sliders, menus, forms). If enabled (set to ON), test every interactive part of your site. You may need to exclude problematic scripts.

JS HTTP/2 push

Function: Similar to CSS HTTP/2 Push, this allows the server to proactively send JavaScript files to browsers over HTTP/2 or HTTP/3. Default: ON. Recommendation: If your server supports HTTP/2 or HTTP/3, enabling this (set to ON) is generally safe and can speed up rendering.

Optimization settings (page optimization > optimization settings)

CSS/JS cache TTL

Function: Sets the Time To Live (in seconds) for minified/combined CSS and JS files stored by LiteSpeed Cache. Default: 604800 seconds (7 days). Recommendation: The default is usually appropriate. If you frequently update your CSS/JS files and need changes to reflect quickly without manual purging, you might consider a lower TTL.

HTML minify

Function: Removes whitespace, comments, and other unnecessary characters from the HTML source code of your pages. Default: OFF. Recommendation: Generally one of the safer minification options to enable (set to ON). Test to ensure no display issues occur.

Inline CSS minify

Function: If HTML Minify is enabled, this option also minifies CSS code found within <style> tags in your HTML. Default: OFF. Recommendation: Enable if HTML Minify is ON and you wish to minify inline CSS. Test carefully.

Inline JS minify

Function: If HTML Minify is enabled, this option also minifies JavaScript code found within <script> tags in your HTML. Default: OFF. Recommendation: Enable with caution if HTML Minify is ON. Inline JS minification can sometimes cause issues. Test thoroughly.

Load CSS asynchronously

Function: Allows page content to start rendering in the browser before all CSS files have been fully downloaded. This can improve perceived load time. Default: OFF. Recommendation: This feature aims to improve perceived load time by displaying essential “above-the-fold” content quickly. However, its effectiveness can vary, and it may require careful configuration and testing. A common side effect is a “Flash of Unstyled Content” (FOUC), where the page briefly appears without styling. Use with caution and test extensively if enabled.

Generate critical CSS

Function: Only applies if “Load CSS Asynchronously” is enabled. This feature attempts to identify the CSS rules necessary for rendering the visible, above-the-fold content of your pages. This “critical CSS” is then often inlined in the HTML to style the initial view quickly, while the rest of the CSS loads asynchronously. This requires communication with LiteSpeed’s QUIC.cloud services or a local critical CSS generation setup. Default: OFF. Recommendation: Can mitigate FOUC when using asynchronous CSS. However, generating accurate critical CSS can be complex and may not always work perfectly out-of-the-box. It often requires fine-tuning and may consume QUIC.cloud credits if using their service.

Generate critical CSS in background

Function: Only applies if “Generate Critical CSS” is enabled. This allows critical CSS generation to occur via a background cron job, preventing potential delays during user page loads. Default: ON (if Generate Critical CSS is active). Recommendation: Keep ON if using Critical CSS generation to improve user experience during the generation process.

Separate CCSS cache post types

Function: Only applies if “Generate Critical CSS” is enabled. Allows you to specify post types (e.g., product, page) or URIs for which separate critical CSS files should be generated. This is useful if different types of content have vastly different above-the-fold styling. Recommendation: Configure if you find that a single critical CSS file doesn’t work well across all parts of your site.

Inline CSS async lib

Function: Only applies if “Load CSS Asynchronously” is enabled. Inlines a JavaScript library into the HTML that manages the asynchronous loading of CSS. Recommendation: This is usually enabled automatically when “Load CSS Asynchronously” is ON. While it attempts to improve the loading process, it can sometimes contribute to issues if not configured correctly with critical CSS.

Load JS deferred

Function: Delays the loading and execution of JavaScript files until after the main HTML content of the page has been parsed. This can significantly improve perceived load time and metrics like First Contentful Paint. Default: OFF. Recommendation: Enabling this (set to ON or “Deferred”) is generally recommended for performance. However, some scripts might rely on being loaded earlier. Test thoroughly. If issues occur, you may need to exclude specific scripts from deferral (an option usually found within the JS settings).

Exclude JQuery

Function: When “Load JS Deferred” or other JS modifications are enabled, this option prevents jQuery (a common JavaScript library) from being deferred or modified. Default: ON. Recommendation: It’s often recommended to keep this ON (meaning jQuery is not deferred/optimized aggressively). Many themes and plugins rely on jQuery being available early in the page load. Deferring it can cause “jQuery is not defined” errors and break functionality. If your site does not heavily rely on jQuery or uses a version loaded in the footer, you might experiment with turning this OFF, but test rigorously.

DNS prefetch

Function: Allows the browser to perform DNS lookups for external domains in the background while the user is Browse the current page. When the user clicks a link to one of these external domains, or resources are loaded from them, the DNS resolution has already occurred, saving time. Default: Empty or includes a few common domains. Recommendation: Add domain names (one per line, e.g., //fonts.googleapis.com, //www.youtube.com) for external services your site frequently uses (like Google Fonts, YouTube embeds, analytics services, CDNs). This can help speed up the loading of resources from these third-party domains.

Remove comments

Function: When enabled, HTML comments (<!-- ... -->) and CSS/JS comments (if their respective minification is on) are removed from the output. Default: OFF (or ON if HTML Minify is ON). Recommendation: Safe to enable (set to ON) if any minification options (HTML, CSS, JS) are active. This further reduces file sizes, but removes potentially useful comments for developers inspecting live code (though original files remain untouched).

Other LiteSpeed cache features

Beyond the settings covered above, LiteSpeed Cache offers many other powerful features typically found in their own sections within the plugin dashboard:

  • CDN (Content Delivery Network) Settings: Configure integration with CDNs like QUIC.cloud CDN, Cloudflare, or others to serve static assets from servers closer to your visitors.
  • Image Optimization: Compress and optimize images (lossy/lossless), generate WebP versions, and manage image metadata. This often uses QUIC.cloud services.
  • Database Optimization: Clean up your WordPress database by removing old revisions, trashed posts, spam comments, transients, etc.
  • Crawler: Proactively simulates visits to your site to refresh cached pages, ensuring visitors are more likely to receive a cached version. This also often uses QUIC.cloud services.
  • Toolbox: Contains various utilities for purging cache, import/export settings, editing .htaccess, reporting issues, and viewing debug information.

Exploring these sections will unlock even more performance gains for your WordPress site.

Conclusion

The LiteSpeed Cache plugin for WordPress is a feature-rich solution for accelerating your website. By carefully configuring its settings, you can dramatically improve your site’s loading times, enhance user experience, and potentially boost your search engine rankings. Remember that while optimal settings can vary from site to site, starting with the recommended defaults and testing thoroughly after each significant change is key to achieving the best results.

If you are a Liquid Web customer and have questions or need assistance configuring LiteSpeed Cache on your hosting account, please don’t hesitate to contact our support team.

Was this article helpful?