Litespeed web server and caching

Litespeed web server and caching

11.01.2023
Author: HostZealot Team
2 min.
1432

Web browsers and how they work is the reason why caching has become a part of our everyday life. If you can't access a site or if you get errors while loading, experts suggest cleaning the cache – it's a standard procedure that helps in most cases.

In our article, we will try to expand our knowledge about caching, delve into specialized documentation, and figure out how to implement this efficient process on your site with the LiteSpeed plugin.

How caching works

First, let's define the terminology. A cache is a place where temporary data, such as photos, page formatting, or text, is stored. The cache is needed so that when the page is accessed again, the information can be presented to the user faster.

Caching is a mechanism for storing data. The caching process occurs in such a way that cache data can be retrieved more easily or more quickly than data from the original source. This is useful for the site owner for several reasons.

Let's start by examining what happens when a visitor enters any of the pages of the site:

  1. First, the web browser sends a request to the URL. The server responds to the request, then sends some number of queries to the database.
  2. The server retrieves information from the database: header, page body, and comments. It then returns this data in the form of an HTML document.
  3. The HTML document itself is read by the browser and displayed to the user as a page. Simply put, the browser loads stylesheets, images, scripts, and other elements in the form of an HTML document.
  4. The browser must send a new request every time a visitor visits your site.

There may be delays or errors at each stage. They are due to the fact that the servers with the necessary elements and information may not respond. And the generation of dynamic pages can be resource-intensive and slow.

This is what caching is for. During this process, copies of items that are frequently requested are created. If the page has been cached, your server or visitors' browsers will provide a static copy of the page.

Caching is suitable for content that does not change over time. You can cache such a page and send it to the user when he opens a certain link.

LiteSpeed (LSCache) – a plugin for WordPress

There are actually several types of caches. LSCache is a "page cache". The task of the page cache is to save a dynamically created page as a static copy of HTML.

Thus, if a visitor revisits the page, a copy will be sent to them immediately. Maintaining a cached page is much faster and requires far fewer resources than dynamically generating elements and data.

Imagine that the pages on your site are not cached. A visitor requests any of those pages, and the following happens:

  • LiteSpeed searches for a page among its saved cache objects and does not find it; 
  • LiteSpeed returns a "cache miss" status;
  • The web application dynamically generates a static HTML document while the visitor waits;
  • The plugin returns a static HTML page to the visitor; 
  • LiteSpeed saves a static HTML document as a cache object for later use.

A few minutes later another visitor requests the same page. The algorithm changes:

  • LiteSpeed searches for a page among the saved cache objects and finds it; 
  • The plugin returns a "cache hit" status;
  • LiteSpeed immediately provides the visitor with a static HTML page.

Once the page is in the cache, the number of steps between a page request and retrieval is reduced, and the slow performance of the web application is eliminated from the algorithm.

From then on, until the cache object expires, visitors requesting that page won't have to wait for the web application. This is why caching improves visitor interaction with the site and reduces the load on your server.

Despite all the advantages of using the cache, there is one small disadvantage that can cause problems for visitors. It is that the client can view old data.

Because the caching is not properly configured, the browser will not be able to verify the cached content. Consequently, the visitor loads outdated content, which negatively affects the user experience. A tool that optimizes the cache is needed.

LSCache supports WooCommerce and is designed to optimize WordPress sites. Rewrite rules, located in the root of the .htaccess file, can be used to control c LiteSpeed Cache Engine.

What does this mean? Parameters about what data should be cached, how long this data can be stored, and what actions will make the cache object obsolete can be edited with LSCache.

For example, you can store more objects, increase or decrease the storage time, and make more fine-tuning. Like other cache management plugins, LSCache allows you to change settings for the best possible caching. If done correctly, it noticeably speeds up WordPress sites. But that's not the only reason to optimize caching.

Using caching plugins improves search engine optimization, it leads to higher search engine rankings. This is especially important if you own an online store and want to increase your sales conversion rate.

What are the key features of LSCache?

The most popular options include:

  • Combining JavaScript and CSS; 
  • CriticalCSS creation in automatic mode; 
  • Minify JavaScript and inline CSS; 
  • image optimization (with or without loss of quality); 
  • Minify (compress the size) of HTML, JavaScript, and CSS files; 
  • Lazyloading function for images and iFrame elements. 

LSCache is a professional plugin and offers an impressive set of parameters for the webmaster. So for beginners, LiteSpeed will seem complicated. But there is no need to worry because in this article we will describe most of the LSCache options and show what you can do to improve the speed of your site.

How to use the LiteSpeed Cache plugin

Step 1: Install LiteSpeed Cache

In the dashboard (located on the left), select the "Plugins" section and click on "Add New". The add plugins menu will open in front of you, and there will be a search box on the right. Enter "LiteSpeed Cache", and then there will be available plugins to install. Hover your cursor over the "Install Now" box.

LiteSpeed is now installed, but the plugin needs to be activated before you can start using it. So do not exit the installation menu until you click on the "Activate" box.

litespeed web server and caching

Step 2: Overview of LiteSpeed Cache

The plugin begins to optimize your site before you even decide to configure anything. But for better optimization, we suggest studying the capabilities of the plugin in depth. LSCache offers two ways to work: 

  1. Serverless. In this mode, caching optimization is not available, but other parameters can be optimized.
  2. Under the LiteSpeed Web Server and LiteSpeedCache license – this option gives you full access to the plugin's capabilities, including caching optimization.

To switch to LiteSpeed Web Server, contact your web hosting company first. 

In the dashboard, you will find a separate item – "LiteSpeed Cache". If you click on it, a number of options will open:

  • Dashboard;
  • General;
  • Cache;
  • CDN;
  • Image;
  • Optimization;
  • Page Optimization;
  • Database;
  • Crawler;
  • Toolbox.

Almost all LSCache optimization options are grouped under LiteSpeed Cache Settings. There are 8 tabs in this extremely large section. Let's look at the capabilities of the main items:

  1. Cache. Here you can activate and deactivate options. Most options are selected by default. If you are unfamiliar with LSCache, leave them alone for now.
  2. TTL. Short for Time-to-Live. In addition to having a caching tool, the system needs to know how long to maintain cached copies before an update is required. This is especially important for dynamic Web sites such as WordPress. Most of the default settings listed here are fine for the first time. Once you have more practice with the plugin, you can come back to this section and make adjustments. Additionally in this section you can force a cache refresh. This is useful if you are testing changes to your site and need to quickly refresh the cache to see if the settings have been implemented correctly.
  3. Purge. The Purge tab contains settings for deleting data stored in the cache. LSCache cleans the cache itself when you update plugins, themes, or WordPress itself.
  4. Browser cache settings. Enabling this option will save you time and resources when visitors return to your site. It transfers some of the cache to their browsers.
  5. Exceptions. Not all sites are suitable for caching, it is best to leave those that interact with sensitive data, such as financial or personal information, un-cached. Such sites should be included in the exclusions list.
  6. Advanced settings. Another tab where it is not recommended to change anything. You will need it if some plugins and widgets conflict with each other.
  7. WooComerce. This section is available to users who have installed the plugin on the site of the online store. Here you will be able to optimize the caching of products and shopping carts.

Each time you make changes to your caching settings, we recommend that you test your site. Incorrect settings disrupt web pages, so it's worth making sure the site is functioning properly.

Step 3: Optimizing the LiteSpeed page

A section that actually changes the output code of the site. This can be minimizing and merging CSS and JSS, or "lazy" loading of images.

Let's take a look at the available options for this section:

  1. CSS Settings. This tab contains everything that has to do with CSS optimization. There are options to minify and merge CSS files.
  2. JS Settings. A similar tab, but relating directly to JS.
  3. Optimization. Optimization of resources on the site. For example, you can manage WordPress Emoji, and select TTL cache for JS/CSS. Disable Google fonts and HTML minification is available.
  4. Media Settings. This is where you configure the delayed loading of resources.
  5. Media Excludes. This tab contains the resources that are excluded from the pending download.
  6. Localization. Allows you to set the automatic copying of external resources (which are used by your site), to the server with subsequent optimization. You can, for example, cache the avatars of commenters.
  7. Tuning. Excluding CSS, JSt, or even entire pages from the optimization list.

While the caching settings work "out of the box," "Page Optimization" requires testing. The reason is that different WordPress sites use different themes and plugins. Some optimization settings are useful for pages, but others can slow the site down due to incompatibilities.

So if you own two different sites on WordPress, the feature will work fine on the first site but slow down on the second. We recommend starting with a basic LiteSpeed cache configuration – when only page caching options are enabled. Then you can explore page optimization options and test which ones give you a boost in your site's load speed.

Caching types

Before dividing them into components, it is useful to understand what is the cache of the site, browser, and server. This information will help you understand how the plugin works:

  1. The site cache, also known as the HTTP or page cache, is a system that temporarily stores data, such as pages, resources, and similar media content, when a page first loads. It remembers the content and can quickly load it when you visit the web page again.
  2. The browser cache is a caching system built into the browser. Files and content are stored in the visitor's browser. The browser cache temporarily stores these types of content: HTML pages, style sheets, CSS scripts, JavaScript, images, and other types of multimedia content.
  3. A server-side cache is a type of cache akin to site caching, except that instead of temporarily storing content on the client side, it is stored on the site server. Server-side caching is also handled and managed entirely on the server, without the involvement of the end-user or browser.

LSCache refers to a server-side type of caching, it serves stored results quickly so that the pages of the site load more efficiently.

Maintaining a cached web page

The easiest way to understand the caching process is to look at how the page is served. Suppose you own a site with caching enabled. When a visitor first clicks a link, the following happens:

  • the server accepts and processes the request;
  • the requested page is turned into HTML, and then a file with this extension is opened by the user's browser.

Because caching is enabled, the server stores this HTML in its RAM. Now, if someone else opens the page, the server no longer needs to process and convert the page into HTML. It simply sends the preformed HTML to the browser.

What happens if you activate the caching feature and then add new information to the site? Will the page be excluded from the cache and, therefore, will the site user see the update?

If caching is configured correctly, the system eliminates such moments on its own. Although caching is essentially storing prepared HTML files, the engine also has a way of emptying the cache (and then restoring it) when certain conditions are met (including publishing new content).

A plugin configured to optimize caching removes the cached version of the main page and archives pages when publishing a new post.

Effect of caching on site speed

Since search engines analyze how fast pages load, this directly affects your search engine ranking. If you use caching plugins, your overall optimization will improve, and your page ranking will increase accordingly.

Summing up

Every site owner has an interest in making their product perform well. LSCache is designed to accelerate performance even without specialized knowledge. The plugin saves site maintenance costs, has a user-friendly interface, and works in semi-automatic mode.

Whether you're starting or already running a successful online business, it's important to remember that a good user experience is key to keeping your visitors coming back to your site. LSCache ensures that your site runs quickly so that visitors have a positive experience.

Related Articles