Differences

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

Link to this comparison view

Both sides previous revision Previous revision
litespeed_wiki:cache:common:gzip-brotli-automatic-conversion [2018/08/17 20:43]
Jackson Zhang
litespeed_wiki:cache:common:gzip-brotli-automatic-conversion [2018/08/20 14:40] (current)
Lisa Clarke Proofreading
Line 1: Line 1:
-====== Brotli ​compression for dynamic responses ​and automatic GZIP and BROTLI conversion for cached pages ====== +====== ​LSWS v5.3 Brotli and gzip Enhancements ​====== 
-LSWS has added brotli ​compression support for a while, but it used to be for static files onlyStarting with LSWS 5.3, Brotli compression for dynamic responses ​has been addedAlsoLSWS will do automatic ​GZIP and BROTLI ​conversion for cached pages.+LiteSpeed Web Server ​has included Brotli ​compression support for a while, but it was only for static files. ​As of v5.3, Brotli compression ​has been added for dynamic responses. ​Additionally, automatic ​gzip and Brotli ​conversion ​has been added for cached pages.
  
-===== Brotli ​compression ​for dynamic pages ===== +===== Brotli ​Compression ​for Dynamic Pages ===== 
-To test brotli ​compression,​ the client (browser) must be Brotli compatible. Google Chrome: Chrome 49+ and Mozilla Firefox: Firefox 44+ are good for brotli ​testing. Also, you will need to run test over an HTTPS connection, can not be HTTP connection. ​+To test Brotli ​compression,​ the client (browser) must be Brotli compatible. Google Chrome ​v49+ and Mozilla Firefox ​v44+ are both good candidates ​for Brotli ​testing. Also, you will need to run tests over an HTTPS connection. It cannot ​be an HTTP connection. ​
  
-wich  ​Negotiation is done via the Accept-Encoding:​ br request header. Servers can add "​br"​ to Content-Encoding:​ br to encode a response with Brotli.+Negotiation is done via the ''​Accept-Encoding:​ br'' ​request header. Servers can add "​br"​ to ''​Content-Encoding:​ br'' ​to encode a response with Brotli.
  
-The following page header shows "Content-Encoding:​gzip", since it is only HTTP connection ​for the same domain.+The following page header shows ''​Content-Encoding:​gzip''​, since it is only an HTTP connection.
  
 {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion1.png?​600 |}} {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion1.png?​600 |}}
-When we test HTTPS connection for the same domain, the header shows "Content-Encoding:​br".+ 
 +When we test an HTTPS connection for the same domain, the header shows ''​Content-Encoding:​br''​.
  
 {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion2.png?​600 |}} {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion2.png?​600 |}}
  
-You should ​test a page without ESI on itsuch as a https wordpress page as indicated as above. LSWS will use brotli ​compression ​as default instead of gzip as far as client supports it(make sure to test HTTPS connection instead of HTTP)However, for ESI pages, gzip compression will be used since LiteSpeed cached ESI pages are optimized for gzip, such as a Magento ​page+Good pages to test include any HTTP WordPress pages without ESI on themlike above. LSWS will use Brotli ​compression ​by defaultinstead of gzipas long as the client supports it(Make sure to test an HTTPS connection instead of HTTP.) For ESI pages, however, gzip compression will be used. This is because ​LiteSpeed-cached ESI pages, such as on a Magento ​site, are optimized for gzip
  
-The following image shows even "​accept-encoding: br" ​sent but still return "​content-encoding: gzip" ​since it is ESI Magento page.+The following image shows ''​Accept-Encoding: br''​ is sentbut ''​Content-Encoding:gzip''​ is returned ​since it is an ESI Magento page.
  
-===== Automatic GZIP and BROTLI conversion for cached pages =====+{{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion3.png?​600 |}}
  
-LSWS 5.3 can cache both br and gzip compressed copy and convert from between them and cache the result. To save on disk space, there is a hit limits to trigger LSWS to save the other compress result. For example, if br version is cached, and client request gzip, it will dynamically decompress br, then compress as gzip, the result is discarded. If there are more than 10 such requests, the gzip version will be cached, next request will be served directly from cache. To avoid misleading benchmark results, LSWS and ADC will immediately cache the result ​for different compression version if a benchmark tool has been detected via User-Agent, not to dynamically expand when Accept-Encoding request header is not set. Currently, "​Apache Bench" is detected.+===== Automatic ​gzip and Brotli Conversion ​for Cached Pages =====
  
-To test the cache enginewe will use two browsers to make such testingone(Chrome) uses BR encoding, one(Firefox) use GZIP encoding.+LSWS 5.3 can cache both Brotli- and gzip-compressed copyconvert between themand cache the result
  
-First, use Chrome, ​you will see "​content-encoding: br" ​on both first visit cache miss and second visit cache hit.+To save on disk spacethere is a hit limit before LSWS is triggered to save the other compression result. For example, if the Brotli version is cached, and the client requests gzip, LSWS will dynamically decompress the Brotli version, re-compress as gzip, serve the resquest, and discard the result. If there are more than 10 such requests, the gzip version will be cached, and the next request will be served directly from cache. To avoid misleading benchmark results, LSWS and ADC will immediately cache the result for a different compression version, if a benchmark tool has been detected via User-Agent. When Accept-Encoding request header is not set, the result will not dynamically expand. Currently, "​Apache Bench" is detected. 
 + 
 +To test the cache engine, we will use two browsers: ​Chrome, ​using Brotli encoding, and Firefoc using gzip encoding. 
 + 
 +First, use Chrome. You will see ''​Content-Encoding: br'' ​on both the first visit cache miss and the second visit cache hit.
  
 First Visit: First Visit:
Line 32: Line 37:
 {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion5.png?​600 |}} {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion5.png?​600 |}}
  
-Second, use Firefox and manipulate Accept-encoding ​to gzip only "Accept-encoding:gzip".+Next, use Firefoxand manipulate Accept-Encoding ​to gzip only: ''​Accept-Encoding:gzip''​.
  
-First Visit, you will still see "​content-encoding: br" ​since it is default setting. Also it is a cached page. +On the first visit, you will still see ''​Content-Encoding: br'' ​since it is the default setting. Alsoit is a cached page. 
 {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion6.png?​600 |}} {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion6.png?​600 |}}
  
-Use "​edit ​and send" ​to change to "Accept-encoding:gzip": +Edit and press **Send** ​to change ​the header ​to ''​Accept-Encoding:gzip''​:
 {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion7.png?​600 |}} {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion7.png?​600 |}}
  
-After "​send"​, you will see the cached page has been auto converted to gzip compression even initial cached version was br compression version.+After sending, you will see the cached page has been auto converted to gzip compressioneven though the initial cached version was Brotli compressed.
 {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion8.png?​600 |}} {{ :​litespeed_wiki:​cache:​common:​lsws5.3-br-gzip-auto-convertion8.png?​600 |}}
  
  • Admin
  • Last modified: 2018/08/20 14:40
  • by Lisa Clarke