Gzip compression reduces the size of the HTML, CSS, and JavaScript files your server sends to a visitor's browser, often by 60-80%. Smaller files travel faster over the network, so pages load quicker, especially for visitors on slower mobile connections. Most hosting accounts can enable it in a few minutes, and it does not require any changes to your website's code.
How to check if compression is already on
Some hosting setups enable Gzip (or the newer Brotli) by default at the server level. Before making changes, check by running your website's URL through an online Gzip test tool, or by opening your browser's developer tools, reloading the page, and checking the Content-Encoding response header on the main HTML request. If it already says gzip or br, you don't need to do anything further.
Enabling compression
In cPanel
- Log in to cPanel.
- Under the Software section, click Optimize Website.
- Choose Compress All Content to compress every file type, or Compress the specified MIME types if you only want certain file types compressed.
- Click Update Settings.
cPanel applies this at the server configuration level, so it takes effect immediately without editing any files.
In DirectAdmin
DirectAdmin does not include a dedicated one-click compression tool in most setups, so compression is enabled through your website's .htaccess file instead.
- Open the File Manager and locate the .htaccess file in your website's root folder (usually public_html). If you don't see one, create a new file named exactly .htaccess.
- Edit the file and add the following at the top:
<IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript AddOutputFilterByType DEFLATE application/javascript application/x-javascript application/json </IfModule>
- Save the file and reload your website to confirm it still loads normally.
Always keep a copy of your existing .htaccess content before editing it. A mistyped rule can bring your entire website down until it's corrected.
What compression won't fix
Gzip only compresses text-based files. It has no effect on images, videos, or already-compressed files like PDFs and ZIP archives. If your website feels slow mainly because of large images, compression alone won't solve that.
For a broader look at improving page speed, including image optimization and caching, see How to Speed Up a Slow-Loading Website.