# Compression Header Analyzer PRO
|Category||Severity||Time To Fix|
|🚀 Performance||Major||30 minutes|
This analyzer checks to see if your application uses appropriate compression headers on your JS and CSS asset files.
Compression headers are so underrated and they can provide a massive performance boost to your application. Picture this: minification optimizes about ~20% file size, whereas compression headers can save 80%!
Just to give you an idea, the performance boost from compression headers is probably equal to that gained by using every other frontend optimization strategy possible (tree shaking, minification, CSS purging, etc.).
# Why Not Compress Everything?
Most image formats are already compressed (except maybe SVG that is basically XML). This is why you must not use gzip or br compression on most image formats that are already compressed. It can do more harm than actually boost performance. Compression is typically useful for text formats (CSS, JS, XML, JSON, etc.).
# How To Setup Compression (Nginx)
If you use Nginx, you can setup compression fairly easily by modifying your
/etc/nginx/nginx.conf file. Here's a small configuration snippet from Matt Stauffer's blog (opens new window) that may help (feel free to customize based on your needs):
# How To Setup Compression On CDNs
Almost all CDNs support automatic compression based on your file type. Check out your CDN's documentation on how to enable compression on your CDN. We have also listed links to the compression docs of popular CDNs in the references section below.
# Skip Condition
This analyzer is skipped for local environments (if the
skip_env_specific configuration option is set to true) or if your application does not use Laravel Mix.
# Related Analyzers
- Difference Between Minification and Compression (opens new window)
- Nginx Compression Guide (opens new window)
- Apache Compression Guide (opens new window)
- AWS Cloudfront Compression Guide (opens new window)
- Cloudflare Compression Guide (opens new window)
- Azure CDN Compression Guide (opens new window)