Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
litespeed_wiki:config:gzip-compression [2017/05/19 15:16]
Eric Leu [Compression verification]
litespeed_wiki:config:gzip-compression [2019/09/16 14:34] (current)
Lisa Clarke [How Can I Use gzip Compression to Save Network Bandwidth?]
Line 1: Line 1:
-===== How can use gzip compression ​to save network bandwidth? =====+====== How Can 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.+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**+Note: **Enable Compression** and **Enable GZIP Dynamic Compression** are enabled by default at installation.
  
-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  +=====Compression Rules===== 
-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".+==== 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: 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 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.+  -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.+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**+==== 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".+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**+==== 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.+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.
  
-=====Compression ​verification=====+=====Compression ​Verification=====
  
-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.+After setting up compression rules as shown above, you can verify ​that it is working ​by opening ​the file URL in your browser in the format: ​''​Server_IP:​Port_num/​path_to_file''​. Enter your browser's Development/​Inspector Tool and navigate to **Network > Headers**. You should see ''​Content-Encoding:​ gzip'' ​as shown below:
  
 {{:​litespeed_wiki:​config:​gzip_true.jpg?​|}} {{:​litespeed_wiki:​config:​gzip_true.jpg?​|}}
  
-If the page returned with none compressed which means no Content-Encoding ​inside the header ​on browserthen you should check if you are not using pre-defined MIME type. +If the page is returned with no compression,​ (i.e. no ''​Content-Encoding'' ​header)verify that you are using pre-defined MIME type. 
-E.g. ''​text/​xml''​ is **not** pre-defined MIME type, so ''​text/​*''​ won’t ​pick it up.+Note that ''​text/​xml''​ is //not// a pre-defined MIME type, so ''​text/​*''​ won’t ​match it.
  
-** How to check MIME type pre-defined ​or not? **+====Adding a New Pre-defined ​MIME Type====
  
-Filter “MIMe type”(e.g. ''​text/​xml''​) in the following path: +Navigate to **Web Admin Console ​Server ​General ​General Settings ​MIME Settings** and open ''​$SERVER_ROOT/​conf/​mime.properties''​. Scan the file for your desired MIME type.
-Web Admin Console ​→ Server ​→ General ​→ General Settings ​→ MIME Settings ​→ Click ''​$SERVER_ROOT/​conf/​mime.properties''​+
  
-If the filter result ​is empty, then there are two methods to solve the problem ​you met:   +If your MIME type is not thereyou can add it in one of two ways:   
-  ​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 {{:​litespeed_wiki:​config:​compressible_type.jpg?​|}}+  ​Method 1: Navigate to **Web Admin Console → Server → Tuning → GZIP Compression → Edit → Append Compressible Types** and append MIME type (e.g. ''​text/​xml''​) to the list manually. ​Save and then Graceful Restart{{:​litespeed_wiki:​config:​compressible_type.jpg?​|}}
  
-  ​Method 2: Please add MIME type entry(E.g.Suffixes:''​text/​xml'',​ Mime type:''​text/​xml''​) manually in the following path: Web Admin Console ​→ Server ​→ General ​→ General Settings ​→ MIME Settings ​→ Click ''​$SERVER_ROOT/​conf/​mime.properties'' ​→ Add → Enter Suffixes and Mime Type → Save → Graceful restart. ​\\ {{:​litespeed_wiki:​config:​mimetype-add.png?​|}} {{:​litespeed_wiki:​config:​mime-entry.png?​|}} +  ​Method 2: Navigate to **Web Admin Console ​Server ​General ​General Settings ​MIME Settings**, click on ''​$SERVER_ROOT/​conf/​mime.properties'' ​and add the MIME type entry under **Suffixes** and **MIME type** (e.g.''​xml''​ and''​text/​xml''​). ​Save and then Graceful restart.{{:​litespeed_wiki:​config:​mimetype-add.png?​|}} {{:​litespeed_wiki:​config:​mime-entry.png?​|}} 
-  * From above examples, you can add MIME type as you want, e.g. text/css, text/js, text/x-js.+  * **Note**: ''​text/​xml''​ is just an example. You can add any MIME type you wish: ''​text/css''​''​text/js''​''​text/x-js'',​ etc.
  • Admin
  • Last modified: 2017/05/19 15:16
  • by Eric Leu