cPanel

Turn on compression with cPanel Optimize Website

Make pages smaller and faster with the cPanel Optimize Website tool: compress all content or only chosen MIME types, check that it works, and avoid conflicts with cache plugins.

BeginnercPanel hosting2 min read

Text files such as HTML, CSS, JavaScript, JSON and SVG compress very well, often to a quarter of their size. Sending them compressed makes pages load faster, especially on mobile. cPanel's Optimize Website tool turns server compression on for your whole account with one setting.

Before you start

  • Check whether compression is already active (it often is on LiteSpeed servers or through a cache plugin). See Check that it works below.
  • Images (JPG, PNG, WebP) and videos are already compressed; compressing them again gains nothing.

Enable compression

  1. Open cPanel → Software → Optimize Website.
  2. Choose one option:
    • Disabled: no compression.
    • Compress All Content: compress every response. Simple, and the server skips types that do not benefit on most setups.
    • Compress the specified MIME types: list types separated by spaces.
  3. For the second approach, a good list is:
    text/html text/plain text/xml text/css text/javascript application/javascript application/json application/xml image/svg+xml
  4. Click Update Settings.

cPanel writes the rules into public_html/.htaccess, so they apply to the primary domain and folders below it. Addon domains with their own document root outside public_html may need the same rules in their own .htaccess.

Check that it works

  • In the browser, open developer tools (F12) → Network, reload, click the page request and look for content-encoding: gzip or br in the response headers.
  • From a terminal:
    curl -sI -H "Accept-Encoding: gzip, br" https://example.com/ | grep -i content-encoding

An answer of br means Brotli, which is even better than gzip; LiteSpeed servers can serve it automatically.

Tip: If your cache plugin (for example LiteSpeed Cache) already enables compression or Brotli, leave Optimize Website disabled to avoid duplicate rules. One source of compression is enough.

Compression is only one part of speed

For a noticeably faster site, combine compression with page caching, optimised images and a current PHP version. See why is my website slow? and LiteSpeed page optimisation.

Troubleshooting

  • Garbled characters or a download prompt: content is compressed twice (by a PHP app and the server). Disable compression in the app or in Optimize Website.
  • 500 error after saving: the .htaccess has a conflict; restore a backup of the file or see fix 500 errors.
  • No content-encoding header: a CDN in front of the site may compress or strip it; check the CDN settings.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.