August Hosting OFFER, 60% OFF for 6 MONTHS. Offer Includes Website, VPS and WordPress Hosting Plans. USE CODE "AUGUST22"
  • Days,
  • Hours,
  • Minutes,
  • Seconds

How do I enable gzip compression on my website?

You can enable this for any website (home-made, WordPress, Joomla, etc.) with gzip using the Apache module mod_deflate.
To do this, you first need to create a file in your public_html directory called ".htaccess" or edit your existing .htaccess file.

The .htaccess file is a configuration file in which you can configure many things, of which compression is just one.

If you want most things to be compressed, you can just add the following to your .htaccess file:


AddOutputFilter DEFLATE text/html text/css text/plain application/xml application/javascript application/json application/rss+xml application/atom+xml text/javascript

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

The full documentation on using this mod_deflate can be found here:

http://httpd.apache.org/docs/2.4/mod/mod_deflate.html

Alternatively, in a PHP based website you can implement gzip compression of the PHP output in the PHP code itself.

This is done using ob_gzhandler which is done as part of the ob_start function. The full documentation on this can be found here:

http://php.net/manual/en/function.ob-gzhandler.php

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

 When I try and view my website I get an HTTP Error 403 - Forbidden message.

A '403 Forbidden' message means that the browser has requested a page that it is not permitted to...

 My links are not working. What is wrong?

First of all, check that the link is correctly spelled, and that the correct case is used -...

 I've put up my site but I still see the standard index page. What's up?

When we create a hosting package, we place a simple index.html holding page into the public_html...

 How do I set up 404/500 error pages?

This article covers two ways to set up 404/500 error pages, but there are many additional methods...

 How do I set up 404/500 error pages?

This article covers two ways to set up 404/500 error pages, but there are many additional methods...

Powered by WHMCompleteSolution