Page speed : How Enable text compression on your server
Page speed : Server text compression
Text-based resources should be served with compression to minimize total network bytes. The Opportunities section of your Lighthouse report lists all text-based resources that aren’t compressed:
Page speed : How Lighthouse handles text compression #
Lighthouse gathers all responses that:
- Have text-based resource types.
- Do not include a
content-encoding
header set tobr
,gzip
, ordeflate
.
Lighthouse then compresses each of these with GZIP to compute the potential savings.
If the original size of a response is less than 1.4KB, or if the potential compression savings is less than 10% of the original size, then Lighthouse does not flag that response in the results.
The potential savings that Lighthouse lists are the potential savings when the response is encoded with GZIP. If Brotli is used, even more savings are possible.
Page Speed : How to enable text compression on your server #
Enable text compression on the server(s) that served these responses in order to pass this audit.
Configure your server to compress the response with Brotli, if the browser supports it. Brotli is a newer compression format, but it’s not universally supported in browsers. Do a search for “how to enable Brotli compression in <server>
” to learn how to implement it, where <server>
is the name of your server.
Use GZIP as a fallback to Brotli. GZIP is universally supported in all modern browsers, but is less efficient than Brotli. See Server Configs for examples.
Check if a response was compressed in Chrome DevTools #
To check if a server compressed a response:
- Press
Control+Shift+J
(orCommand+Option+J
on Mac) to open DevTools. - Click the Network tab.
- Click the request that caused the response you’re interested in.
- Click the Headers tab.
- Check the
content-encoding
header in the Response Headers section.
To compare the compressed and de-compressed sizes of a response:
- Press
Control+Shift+J
(orCommand+Option+J
on Mac) to open DevTools. - Click the Network tab.
- Enable large request rows. See Use large request rows.
- Look at the Size column for the response you’re interested in. The top value is the compressed size. The bottom value is the de-compressed size.
[amazon box=”B084LF85PC” “small”]