D
D
dvachek2014-11-21 20:32:56
Nginx
dvachek, 2014-11-21 20:32:56

gzip not working in nginx, what's the problem?

There is one server with these gzip settings:

##
  # Gzip Settings
  ##

  gzip on;
  gzip_disable "msie6";
        gzip_min_length 1024;
  gzip_http_version 1.0;

  
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

When the page is opened, there is no compression, if you look at the headers of the issued page, then there is nothing about it:
Connection:keep-alive
Content-Type:text/html; charset=UTF-8
Date:Fri, 21 Nov 2014 17:31:18 GMT
Server:nginx/1.6.2
Transfer-Encoding:chunked
X-Powered-By:PHP/5.5.19-1~dotdeb.1

what is the problem here? And static files with the same headers are not compressed.
When checked by this service: www.gidnetwork.com/tools/gzip-test.php shows
that there is compression, although when viewing the page in a browser, there is no Content-Encoding: gzip header. And the size of the downloaded file (page) and the content from it are the same, i.e. there is no compression.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
VA_ic2b, 2015-05-25
@VA_ic2b

Take a look at the definition of nginx MIME types - mime.types file. For js files, recent versions use application/javascript instead of text/javascript. If so, change gzip_types to match this definition.

I
Igor, 2014-11-21
@merryjane

1. Content-Type:text/html is not listed in gzip_types;
2. You may be getting less than 1024 which is specified in gzip_min_length.

E
Elena, 2014-11-21
@Nidora

Reconsider or everything is correctly indicated:
yapro.ru/web-master/apache/nastroyka-gzip-v-nginx.html

P
Power, 2014-11-21
@Power

Is the client you're checking with exactly sending an Accept-Encoding: gzip header? Do you have compression on toster.ru?
Perhaps someone cuts out this header, for example, in ancient times, the outpost firewall did this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question