This is an old revision of the document!

LiteSpeed Web Server can send compressed responses for both static and dynamically-generated content. The level of compression and situations under which it occurs can be configured in the gzip Compression section of the WebAdmin console (Configuration > Server > Tuning). You first must make sure Enable Compression is set to “Yes”. Then set compression rules for static and dynamic content separately.

Static content

When a request for a static file comes in (and compression is enabled), the web server first looks for a corresponding gzip-compressed version in the Static gzip Cache Directory. The compressed file found in this directory will be used if it is newer and smaller than the original one. If the compressed file does not exist or is out of date, the web server can create/update the gzip-compressed file automatically if Auto Update Static is set to “Yes”.

Because compression is pretty server intensive, the web server will only compress files with a potentially high compression rate based on following rules:

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 Min Static File Size and the Max Static File Size.

Be careful not to set the Max Static File Size too large. The server cannot process other requests while it is compressing a static file. Compressing very large files will thus result in delayed service.

Dynamic content

The web server can perform run-time compression for dynamically generated content as well. To turn on compression for dynamic content, both Enable Compression and Enable Dynamic Compression must be set to “Yes”.

Compression levels

Both static and dynamic file compression can be tuned to your server and network capabilities using Compression Level (Static File) and Compression Level (Dynamic Content). Better compression (a higher number) will save bandwidth, but will use more memory and CPU cycles. Your specific CPU and bandwidth saving needs determine the ideal configuration for your system.

After setting up by above guidance. You can verify it by opening URL with Server_IP:Port_num/path_to_file on browser, then You will see Content-Encoding: gzip by entering button F12(DevTools) → Network → Headers as the following picture.

If the page returned with none compressed which means no Content-Encoding inside the header on browser, then you should check if you are not using pre-defined MIME type. E.g. text/xml is not pre-defined MIME type, so text/* won’t pick it up.

How to check MIME type pre-defined or not?

Filter “MIMe type”(e.g. text/xml) in the following path: Web Admin Console → Server → General → General Settings → MIME Settings → Click $SERVER_ROOT/conf/

If the filter result is empty, then there are two methods to solve the problem you met:

  • Method 1: Please append MIME type(E.g. text/xml) manually in the following path: Web Admin Console → Server → Tuning → GZIP Compression → Edit → Append Compressible Types → Save → Graceful Restart
  • Method 2: Please add MIME type entry(E.g.Suffixes:xml, Mime type:text/xml) manually in the following path: Web Admin Console → Server → General → General Settings → MIME Settings → Click $SERVER_ROOT/conf/ → Add → Enter Suffixes and Mime Type → Save → Graceful restart.
  • From above examples, you can add MIME type as you want, e.g. text/css, text/js, text/x-js.
  • Admin
  • Last modified: 2017/05/19 15:42
  • by Eric Leu