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 use gzip module of nginx to compress documents. When gzip is enabled nginx will automatically send content-ending of gzip with HTTP headers, right?

Without adding any PHP header header() or HTML meta http-equiv, this works perfectly. However, I have seen on online tutorial for adding header for gzip whether by PHP or HTML meta to assist browser to process gzipped data.

Is it really needed? Since I was not sure if this is needed on some conduction (that I am not testing), I asked this question for further clarification of the issue.

share|improve this question
up vote 1 down vote accepted

Nginx compresses data on mime type. For static files it uses the mime.types file for this but for data from a backend you do need to set the mime type unless the default is already text/html or you've added the default to the types of be compressed. See

share|improve this answer
Yes, it compress text/html (by default), and without HTML or PHP header it successfully send gzip header. My question is whether I need to add gzip meta or header too? or nginx does this automatically? – All Mar 26 '12 at 8:03
Nginx will automatically add the gzip header. – Martin Fjordvald Mar 27 '12 at 6:37
Then adding PHP header is useless, right? – All Mar 27 '12 at 6:38
If nginx is compressing it then it will make sure the response is properly formatted. You don't need to do anything at all on PHP side. – Martin Fjordvald Mar 27 '12 at 8:09

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.