Enabling GZIP & Brotli Compression
Compression is the "zipping" of your website files before they are sent to the browser. Just like you zip a folder to email it, your server zips HTML, CSS, and JS files to send them to the visitor. The browser then unzips them instantly.
GZIP vs. Brotli
- GZIP: The industry standard for decades. Good compression, supported by everything.
- Brotli: The modern standard developed by Google. It compresses text files 15-20% better than GZIP.
Goal for 2026: You should be using Brotli.
Step 1: Checking Your Current Status
Before making changes, check if you are already compressed.
- Go to GiftOfSpeed GZIP Test.
- Enter your URL.
- It will tell you if GZIP or Brotli is enabled.
Step 2: Enabling Brotli on Cloudflare (Easiest)
If you followed our CDN guide and are using Cloudflare, this is already done!
- Go to Cloudflare Dashboard.
- Speed > Optimization > Content Optimization.
- Toggle Brotli to On.
This is the preferred method because Cloudflare's servers are highly optimized for this.
Step 3: Enabling GZIP/Brotli on Apache
If you aren't using Cloudflare, you need to enable compression on your origin server.
Add this to your .htaccess file for GZIP:
<IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE font/opentype </IfModule>
Note: Enabling Brotli on Apache/Nginx usually requires root access to install the module. If you are on shared hosting, ask your support team.
Step 4: Enabling GZIP on Nginx
Add this to your nginx.conf or server block:
gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
Conclusion
Compression is non-negotiable. It drastically reduces the amount of data traveling over the wire, which is especially critical for mobile users on unstable networks.
Next, we will look at the foundation of your site: Choosing the Right Hosting Provider.