Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I saw from an online tester that my HTML can be compressed about 90%! Is it good practice to use gzip or not? I see that lot sites don't use it.

For me it would improve traffic, as some pages contain a lot of data (120 KB of HTML without the images) which can be compressed to a few kilobytes.

share|improve this question
add comment

3 Answers 3

up vote 12 down vote accepted

Yes. 120KB for HTML alone(!) can be compressed greatly. Together with the CSS and JavaScript files. This will speed up the browsing experience for your users and save you bandwidth on your server.

You could implement the compression using your server-side script and cache the compressed files, thus easing the pressure on the CPU on busy servers.

share|improve this answer
add comment

Yes, there is almost no reason I can think of to not use GZIP at all times. It's like getting free bandwidth, and it is universally supported. Always have it on!

The only possible downsides are

  1. If you are on a shared host with very limited CPU resources, as the compression is done on the server and it does take a tiny bit of server CPU. The server would have to be very overloaded and/or extremely old for this to matter in practice, though.

  2. If you serve up very large (and by large I mean 400 kilobytes and up) dynamic web pages. Compressing very large dynamic content on the fly can be prohibitively expensive.

But these are both rare edge conditions in my experience; 99% of the time HTTP compression is a clear win.

share|improve this answer
    
In addition I will say that some hosting providers make complains of forums and other widely used website that use gzip cause the higher CPU use that Jeff mentioned above. The answer is YES but check your hosting provider options first. –  Ilian Iliev Oct 28 '10 at 10:12
add comment

Is it good practice to use gzip or not?

Depends upon your webserver's environment.

If your server is running low on idle CPU time, adding GZIP deflation could actually slow down the rate at which your server responds to requests.

If you're not presently dealing with a CPU bottleneck, however, GZIP deflation is a great idea but only for plain-text files.

Most image file formats (i.e. PNG, JPG, GIF) are already compressed and GZIP deflation is a waste of CPU time.

share|improve this answer
    
how can i avoid compressing these files in apache ? –  Parhs Oct 28 '10 at 10:32
4  
Use AddOutputFilterByType directives - see the mod_deflate entry in the Apache manual for further information: httpd.apache.org/docs/2.0/mod/mod_deflate.html –  danlefree Oct 28 '10 at 11:04
1  
Most compressed media format also gain very little benefit from being zipped. That includes MP3, AVI, MP4, MPG, and PDFs. –  Lèse majesté Oct 28 '10 at 13:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.