views:

203

answers:

4

Dear folks,

I enabled gzip compression on my website, and tested with the following tools:

Though, Firefox and all its extensions (Firebug, Yslow and Google Page Speed) say they receive noncompressed content.

text/html is compressed by php's ob_gzhandler, which cares about headers as well.

I don't use proxy.

What am I doing wrong?

A: 

Have you tried just enabling gzip in Apache/your web server instead/as well?

Mike McQuaid
In my country there are no great hosting services, and even shared hosts with mod_deflate enabled are quite expensive. I tried to enable but with no success.
pestaa
+2  A: 

That's not really the answer you might expect, but did you try not compressing out data with PHP, but with Apache ?

This can be done use mod_deflate.

Couple of things :

  • it would mean less calculations for PHP
  • it would also mean (and that's the nicest part ;-) ) that your CSS/JS files could be compresses to ; considering the size of those, nowadays, it might not be a bad thing to compress them...


As a sidenote : to help us figure out what's going wrong with the compression by PHP, could you give more informations ? Like the URL of your site (if it's public), and some code ?


EDIT now that we have the URL : http://ego.pestaa.hu/

When I go to that page, the response's headers are as follow :

HTTP/1.x 200 OK
Date: Sat, 01 Aug 2009 21:53:37 GMT
Server: Apache
X-Powered-By: PHP/5.2.6
**Content-Encoding: gzip**
Vary: Accept-Encoding
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

(using firefox 3.5 with LiveHTTPHeaders extension)

The three testing sites you indicated also say that your page is gzipped.
Did you find what the problem was ?

Are you sure this is not something coming from your browser, that would not send the following header in the request :

Accept-Encoding: gzip,deflate


EDIT after other answer

Quote from the comments :

the source of problem probably isn't my website but my isp/browser/router. One of them may decompress every component before it reaches internal processes.

Oh, if the problem is not your website, I think I totally mis-understood the question -- sorry about that :-( I thought you didn't know how to server gzipped content from your website.
And I think I'm not the only one, btw

If the problem has nothing to do with your website's configuration, then, two possibilities :

  • maybe a mis-configuration of firefox ? If you go to about:config, what does the network.http.accept-encoding say ? For me, it's gzip,deflate
  • if the problem is coming from your ISP or something like that, there's nothing anyone can do...
Pascal MARTIN
My hosting does not provide mod_deflate, I tried. I use minify to compress css/js. The website in question is http://ego.pestaa.hu
pestaa
oh, ok :-( too bad you don't have mod_deflate :-( ; btw, I just tested the URL you gave with FF 3.5, and the page seems to be compressed just fine : using LiveHTTPHeaders, I have a "Content-Encoding: gzip" in the response's headers
Pascal MARTIN
Well, all three sites you indicated in the OP show your content is gzipped ; so, I guess you found how to solve your problem :-)
Pascal MARTIN
No, the source of problem probably isn't my website but my isp/browser/router. One of them may decompress every component before it reaches internal processes.
pestaa
It's good to see you have the content properly compressed. Still, in my network something is missing.
pestaa
Sorry, I absolutly didn't understand the questio, then : I thought the problem was that your website was not served gzipped. I've edited my answer another time ^^
Pascal MARTIN
I wasn't sure how to ask as well, since my browser doesn't receive the content compressed, so how could I make sure if the site is gzipped. I tried my accept-encoding with 'gzip', 'gzip, deflate' and 'gzip,deflate' as well, nothing worked. Thanks for your help, I'll accept your answer.
pestaa
OK, Thanks! And sorry I couldn't help more :-(
Pascal MARTIN
A: 
  • Are you sure you're testing the same URLs with the Firefox extensions?
    • Using the ob_gzhandler in PHP will compress the output of your php pages, but YSlow and others warn you also about uncompressed css/javascript files.
  • Check that the browser is sending the correct headers. A browser usually sends the "Accept-encoding: gzip" header to tell the script/webserver it accepts compressed content. The testing scripts will surely send that but your browser might not.
deathy
+1  A: 

Try the Live Http Headers firefox plugin in addition to the others. It opens a window showing the exact request/response headers as they go back and forward, so you know without doubt what the accept-encoding and response-encoding is.

skaffman
Thanks for the suggestion. This extension also shows that nothing is gzipped. I wonder what could cause this.
pestaa
No idea, but now you know the problem's server-side. The request includes the gzip accept header, yes?
skaffman