Enable text compression Stay organized with collections Save and categorize content based on your preferences.
Text-based resources should be served with compression to minimize total networkbytes. The Opportunities section of your Lighthouse report lists all text-basedresources that aren't compressed:

How Lighthouse handles text compression
Lighthouse gathers all responses that:
- Have text-based resource types.
- Do not include a
content-encodingheader set tobr,gzip, ordeflate.
Lighthouse then compresses each of these withGZIP to compute the potentialsavings.
If the original size of a response is less than 1.4KiB, or if thepotential compression savings is less than 10% of the original size, thenLighthouse does not flag that response in the results.
Note: The potential savings that Lighthouse lists are the potential savingswhen the response is encoded with GZIP.If Brotli is used, even more savings are possible.Enable text compression on your server
Enable text compression on the server(s) that served these responses in order topass this audit.
When a browser requests a resource, it will use theAccept-EncodingHTTP request header to indicate what compression algorithms it supports.
Accept-Encoding: gzip, compress, brIf the browser supportsBrotli(br) you should use Brotli because it can reduce the file size of the resources more than theother compression algorithms. Search forhow to enable Brotli compression in <X>, where<X> is the name of your server. As of December 2022 Brotli is supported in all major browsers except Safari on iOS. SeeBrowser compatibilityfor updates.
Use GZIP as a fallback to Brotli. GZIP is supported in all major browsers,but is less efficient than Brotli. Refer toServer Configsfor examples.
Your server should return theContent-EncodingHTTP response header to indicate what compression algorithm it used.
Content-Encoding: brCheck for response compression
To check if a server compressed a response:
PressControl+Shift+J (orCommand+Option+J on Mac) to open DevTools.Click the Network tab.
- PressControl+Shift+J (orCommand+Option+J on Mac) to open DevTools.
- Click theNetwork tab.
- Click the request that caused the response you're interested in.
- Click theHeaders tab.
- Check the
content-encodingheader in theResponse Headers section.
content-encoding response header.To compare the compressed and decompressed sizes of a response:
- PressControl+Shift+J (orCommand+Option+J on Mac) to open DevTools.
- Click theNetwork tab.
- Enable large request rows.SeeUse large request rows.
- Look at theSize column for the response you're interested in. Thetop value is the compressed size. The bottom value is the decompressedsize.
See alsoMinify and compress network payloads.
Stack-specific guidance
- Drupal: Text-based resources should be served with compression (gzip, deflate or brotli) to minimize total network bytes. Consider using a CDN that natively supports this, or configure the web server to perform this operation.Learn more.
- Joomla: Enable the Gzip Page Compression setting (System >Global configuration >Server).
- WordPress: Enable text compression in your web server configuration.
Resources
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2019-05-02 UTC.