1

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.

1 Answer 1

1

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

4
  • 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?
    – Googlebot
    Mar 26, 2012 at 8:03
  • 1
    Nginx will automatically add the gzip header. Mar 27, 2012 at 6:37
  • Then adding PHP header is useless, right?
    – Googlebot
    Mar 27, 2012 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. Mar 27, 2012 at 8:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .