How can I use gzip compression to save network bandwidth?

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.

litespeed_wiki/how_can_i_use_gzip_compression.txt · Last modified: 2015/01/21 17:04 by Jackson Zhang