Portal Home > Knowledgebase > Articles Database > GZIP Compression


GZIP Compression




Posted by turbowarp, 10-27-2013, 01:55 AM
Is it a good thing to add mod_deflate and enable gzip compression for websites? How well does it work? Does it work better for particular websites than others? Does it break things or cause other problems?

Posted by BrianHarrison, 10-27-2013, 02:24 AM
It can certainly help reduce page load time for your users, but remember there are overheard prices associated with compressing the files so if you're already running a high CPU load on your server then you probably won't want to enable gzip. Try it out during non-peak traffic hours and monitor how server load responds. We often enable gzip for .htm, .html, .php, .js, .css extensions.

Posted by ultraweb, 10-27-2013, 07:20 AM
you should use it

Posted by LiteSpace-Smith, 10-27-2013, 07:28 AM
to effect GZIP Compression is very helpful when we open the site pages and better combine well with gzip for. htm,. html,. php,. js,. css extensions as described by @BrianHarrison

Posted by supportexpertz, 10-27-2013, 07:58 AM
Mod_deflate is an apache module that can be used to compress data using gzip compression before sending it to the user. For bandwidth intensive websites, using this feature can offer a benefit, as the server is compressing data before sending it you will be using less bandwidth. The major drawback to using mod_deflate however is that the server may need to use more resources to compress each file and this in turn can cause performance issues on older servers.

Posted by gPowerHost, 10-27-2013, 10:33 AM
From a customer's standpoint it is great. All modern browsers support it. If you are setting it up with cPanel or properly yourself it will fallback to uncompressed if anyone doesn't have a modern browser made in the last decade. Sure it takes a but of overhead, but so does a soft firewall. And customers are increasingly asking for this and it is a strong selling point. In addition to GZIP Compression there is browser cache. Working with customers you can do something like: Of course change the settings based on needs. This dictates to many browsers how long to cache files on the client device. This is a big saver of bandwidth and again a good service to make sites load faster.

Posted by gPowerHost, 10-27-2013, 10:53 AM
Sorry sometimes I forget to answer the question fully and I do apologize! Others explained how it works, but it simply compresses the file prior to sending (using GZIP) and then the browser simply decompresses it. It sounds complicated and even maybe not efficient. But it actually ends up causing the page to load faster. Why? Because the weak link is in that long network pipe. Compression and deflating is done easily (on modern servers and computers). So the time saved to send the compressed resource certainly makes up for any time to zip and unzip. I will say it isn't wise to compress images, audio and video this way. Those types of resources are best compressed via other means. Namely, when created or as a batch job once on a stack or files. Otherwise, most media types are already compressed and if you specify them to GZIP then you are waisting server resources to get unlikely benefit. So the compression of text it what is normally done. So sites with text files that you specify will benefit to the degree they have that resource. Try a website speed tool like: http://tools.pingdom.com/fpt/ (just an example, pick any one) and try your sites with GZIP and without (turn it on and off). See how well it impacts. I've never seen negative impact, but anything is possible. Seriously, on thousands of sites we have no issues with it, when properly configured. So I'd say issues are not really a factor. Sure there may be one and you can turn it off for that client (or yourself). I will add that it does improve SEO page ranking. Another selling benefit! Google and other providers love it. I think it saves them money! Last edited by gPowerHost; 10-27-2013 at 10:56 AM. Reason: typos!

Posted by turbowarp, 10-27-2013, 11:04 AM
I will turn it on and watch my resources and adjust the compression level accordingly. Thanks all for your posts.

Posted by turbowarp, 10-27-2013, 08:29 PM
I have cPanel version 11.38x ... it offers pigz, does pigz replace gzip?

Posted by gPowerHost, 10-27-2013, 11:37 PM
Yes. It is a version that works on modern, parallel, multi-processor servers. So you are good with that.

Posted by Kailash12, 10-28-2013, 01:30 AM
It is a good idea to enable gzip compression for static contents like css, js, images, html etc.

Posted by turbowarp, 10-29-2013, 10:45 AM
I have enabled gzip. I found this tool to test gzip compression: HTTP Compression Test On this VPS I have 2 cPanel accounts. On one of the cPanel accounts, I can set "Website Optimization" to compress and it stays enabled. On the other cPanel account, same VPS, Website Optimization will not stay enabled. What's the problem?

Posted by gPowerHost, 10-29-2013, 10:56 AM
By not staying enabled are you talking about in cPanel when you try and set it up? Because out of the box this should work without modification in cPanel, except setting up Apache's mod_deflate. We do it many times a day: cpanel->Software/services->Optimize Website->select: Compress the specified MIME types-> Paste in your MIME types like: ->click Update Settings and it should report back "Website optimization preferences updated." Do you get an error anywhere? Sorry if I oversimplified things, but can you expand on how you determine it is not staying enabled?

Posted by turbowarp, 10-29-2013, 11:05 AM
No, I don't get any errors, when I select the "Specified MIme Types" and click "Update Settings" I get this: But, when I go back to look, the radio button is back on "Disabled". But, on the other cPanel account (same vps) it stays enabled.

Posted by gPowerHost, 10-29-2013, 11:34 AM
OK. Obviously the accounts are one the same box right? Are they separate users? And you verified that it is both not enabled and the test site is also verifying this? My theory is that it is possible for easy apache to have error (failing the dry run?) upon compilation and maybe mod_deflate was not enabled for that user. Try to rebuild apache and watch the output.

Posted by gPowerHost, 10-29-2013, 11:42 AM
Also check the .htaccess, php.ini and httpd.conf (don't edit that file) file on that account and see that some script (or someone) didn't add some code to disable mod_deflate. Report back anything like: ...

Posted by gPowerHost, 10-29-2013, 11:20 PM
One more thing. Apparently cpanel adds or modifies an .htaccess file in your home directory. I'm not talking about the one that might be in /public_html/. Check out that file, and the permissions. Maybe the permissions are too tight. While locking down an .htaccess as tight as 404 will work, it will prevent cpanel from modifying it. So you can either change the permissions to say, 604, either temporarily (while you enable the feature in cpanel) or permanently, if your security policy is accordingly. Note: I can't tell you what permissions you should run on your server. But I usually never recommend anything looser than 604 for .htaccess If cpanel wrote to home/user_account/.htaccess it might look somerthing like this:



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
does thsi sound good? (Views: 568)