1. Websta Hosting
Performance & CDN

Enabling GZIP / Brotli Compression

Enabling GZIP / Brotli Compression

Compression reduces the size of files transferred between your server and visitors, making your site load faster.

Enable GZIP via .htaccess

Add to public_html/.htaccess:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml
    AddOutputFilterByType DEFLATE text/css application/javascript
    AddOutputFilterByType DEFLATE application/json application/xml
    AddOutputFilterByType DEFLATE image/svg+xml font/ttf font/woff font/woff2
</IfModule>

Enable Browser Caching via .htaccess

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType text/html "access plus 0 seconds"
</IfModule>

Verify Compression Is Working

Use gziptest.com or run:

curl -H "Accept-Encoding: gzip" -I https://yourdomain.com | grep -i content-encoding

Should return: content-encoding: gzip

Brotli Compression

Brotli is more efficient than GZIP. If your server supports it (LiteSpeed or Nginx with brotli module), enable it via your caching plugin or contact support.

Still need help?

If this article didn't answer your question, our support team can help.

Contact support
All articles More in Performance & CDN