Enable GZip in .htaccess for Joomla or any Website

  • Follow

For website developers or webmasters, there is a quick and simple way to speed up the loading of your website. Those using Joomla CMS websites will notice a serious increase in performance, but even a standard HTML/CSS website can notice a 45% reduction in the landing page's required download size.  You better get GZip enabled.

GZip is a nice feature of today's servers. GZip is essential for speeding up your load times on your website by having the server compress the information before it is sent out to the requesting computer. Apparently, Google takes notice of these things as well as its recommended adjustments after running PageSpeed. In most cases, Javascripts can be reduced in size by more than half. That is very important in any CMS operated website but Joomla websites benefit tremendously from this little tweak.  These tweaks to enable GZip will work on Joomla versions 1.5 - 3.6.

Joomla does have a option to enable GZip in the site settings in the back-end. However, this only effects text, html, and maybe CSS. It does not compress images or javascript. Those familiar with Joomla know that it relies on Javascript heavily. Jquerry, MooTools, and Bootstrap javascripts transfer times can be cut in half.  Jquery or Bootstrap can be disabled for huge savings on requests and website loading speed if your website doesn't utilize those.

These improvements can be used on regular HTML websites as well. So for those looking to improve website speed load times as well as decrease bandwidth on your server, just add these lines to your .htaccess inside of the root directory. I have personally tested this on several websites. It doesn't have to be inserted anywhere in particular so it can simply be inserted at the bottom of the file. I have tried so many other configurations to no avail, and this one is by far the simplest to implement.

    <ifmodule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript
    #End Gzip

The "if" statement is merely to determine if the server has the mod_deflate enabled or not. If you are unsure, definitely leave the "if" statement intact, otherwise the lines can be removed.  You may add other lines of code to include or exclude certain types of files. Please search the internet for those. You can always check PageSpeed to see if it is now seeing that you have correctly enabled Gzip.

Some important notes:  GZip is a resource intensive service.  Massive website with large amounts of traffic can see detrimental effects if using GZip and PHP websites especially on shared servers.  Most users will never see the amount of traffic needed to create problem and to remedy the situation you could (and should already) be using cached pages.

We try to give credit where credit is due. This information was originally found at Sal's Code as I was building this website.

Menu at bottom of the page.
Please remember to Plus1 and Follow!
  • Follow