Bobcares

Compression in LiteSpeed web server: Easy setup

by | Oct 13, 2022

.Let us take a closer look at the role and the usage of the Compression in LiteSpeed web server and the configurations associated with it with the support of our Server Management Support Services at Bobcares.

Litespeed Web Server and compression

Compression in LiteSpeed web server

Allow the gzip or brotli comparessed answers for both static and the created material. This allows the LiteSpeed Web Server can save network traffic. We can set up the level of compression and the situations in which compression happens. We can set this up from the WebAdmin console’s gzip compression section.

First, we have to ensure that Enable Compression is Yes. After that apply compression rules for static and dynamic content one by one. Please keep in mind that ‘Enable Compression’ and ‘Enable GZIP Dynamic Compression’ will be active by default after the install.

Compression Rules and Litespeed Webserver

Static Content

When we receive a request for a static file (when compression is active). The web server first searches the static gzip cache section for a corresponding gzip-compressed version. If the compressed file found in this scetion is fresher and smaller than the original, it will use it first.

Consider that the file after compression does not exist. In this case the web server can automatically create or update it if Auto Update Static is Yes.

As compression is a server rich procedure, the web server will only compress files with a high compression rate. They have to meet the following:

  • The MIME type is set in Compressible Types (for example: text*,application/x-javascript,application/javascript,application/xml, image/svg+xml).
  • The file size is between the Minimum and Maximum Static File Sizes.

Make sure that the Max Static File Size doesn’t exceed a certain limit. While compressing a static file, the server cannot process any other requests.

Note that as a result of compressing large files, the service will stop for a while.

Dynamic Content

For content that is dynamic, the web server can also conduct run time compression. Enable Compression and Enable Dynamic Compression must both be Yes. This will enable compression for dynamic content.

Compression Levels in LiteSpeed web server

Compression Level and Compression Level can tailor static and dynamic file compression to the server and network potential. Better crushing saves Bandwidth while using more memory and CPU cycles. CPU and Bandwidth saving determine the optimal system setup.

Verification

After setting up the compression rules, we can test them by using the file URL in the browser:

Server IP: Port num or path to file.

Then, open the browser’s Development/Inspector Tool and navigate to Network > Headers. Following that, we should see: Content-Encoding: gzip

Check if we are using a predefined MIME type if the page returns with no compression. As the text or xml is not a pre-defined MIME type, text/* will not match it.

Adding a New Pre-defined MIME Type

To add a predefined MIME type, go to **Web Admin Console > Server > General > General Settings.

MIME Settings**, then go to $SERVER ROOT/conf/mime.properties. Scan the file for the MIME type we want.

If the MIME type is not there, we can add it in one of two ways:

  1. Go to Web Admin Console > Server > Tuning > GZIP Compression > Edit > Save. Manually append Compressible Types and the MIME type to the list. Save and then restart.
  2. Navigate to Web Admin Console > Server > General > General Settings > MIME Settings, then click on $SERVER ROOT/conf/mime. properties and add the MIME type item under Suffixes and MIME type. Gracefully resume after saving.

Disabling at the Virtual Host Level

Gzip compression is often ‘enable or disable’ at the server level. However, we can control the gzip compression for a specific virtual host via.htaccess without changing the global settings.

There are two methods to disable the gzip:

  1. a rewrite rule
  2. SetEnv/SetEnvIf

The latter is a superior option as it is immune to other rewrite rules.

Rewrite Rule¶

We have to type in the following to the .htaccess file:

RewriteRule . - [E=no-gzip:1]

Be mindful that other rules may have an impact on it.

SetEnv/SetEnvIf

We have to place the following in .htaccess:

SetEnv no-gzip 1

[Need assistance with similar queries? We are here to help]

Conclusion

To conclude we have now gone through all of the configurations on Compression in LiteSpeed web server with the support of our Server Management Support Services.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.