Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was sniffing the response header of one my sites and apparently is not using http compression to deliver responses because I'm not seeing the Content-Encoding: gzip in the response header.

But the weird thing is that phpinfo() shows me HTTP_ACCEPT_ENCODING: gzip,deflate,sdch

Im using a rackspace cloud site (shared hosting, cant access httpdconfig), and I really want to activate http compression but the support guys over there tells me that if the phpinfo() says it, its already on.


share|improve this question

HTTP_ACCEPT_ENCODING means the browser accepts those encodings. It doesn't mean the server is sending those encodings - it's a client side header.

share|improve this answer

What you should do is add this php code to the very begenning of any PHP files that you want to use compression:


Often times there is a header file that is included by all files, a good example is the database config file. As long as this line of code is added before your program does a print() or echo() then you are golden.

This will buffer all of the output that the PHP page builds, and then gzip's it before sending it to the browser. If you are just serving flat html files, then you could write a simple PHP access page to read the .html file and print it:

share|improve this answer

Your Answer


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.