Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

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 http://wiki.nginx.org/HttpGzipModule#gzip_types

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
1  
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
1  
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
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.