Economicalhost · Knowledge Base
Knowledge Base › PHP & Performance › How to Enable Gzip Compression
PHP & Performance

How to Enable Gzip Compression

Gzip compresses your pages before sending them, often cutting transfer size by 70%. It is a quick, high-impact speed win added through .htaccess.

Step-by-step

  1. Open Files → File Manager and enable "Show Hidden Files" in Settings.
  2. Open public_html/.htaccess (create it if missing) with right-click → Edit. Back up the current content first.
  3. Add a compression block using mod_deflate, for example:
    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json text/xml
    </IfModule>
  4. Save the file.
  5. Test compression with any online "Gzip test" tool, or your browser dev tools Network tab (look for content-encoding: gzip).
  6. Combine with caching for the best result — see browser caching.

💡 Good to know

  • Many caching/optimization plugins enable Gzip for you — check before adding rules manually.
  • A wrong .htaccess rule causes a 500 error; keep a backup of the original.
  • Gzip plus caching plus a CDN is the classic speed trio.