V
V
vasiatka2015-12-20 13:53:49
Nginx
vasiatka, 2015-12-20 13:53:49

Caching does not work in nginx when serving content using gzip_static. Why?

Static caching enabled on the server

http {
  ......
  sendfile on;
  gzip_static on;
  gzip_http_version 1.1;
  gzip_proxied any;
  gzip_types application/x-javascript text/css;
  gzip_disable "msie6";
 gzip_vary on;
......
}

For a domain:
server{
  ............
  location ~* \.(jpg|js|jpeg|gif|png|css|gz)$ {
      expires      30d;
      if (!-e $request_filename) {
        return 404;
      }
    }
  .................
}

After gzip_static was enabled, files began to be given out compressed, but caching in the browser does not work for them.
Firefox for compressed files always returns status 200, for other css, js status 304.
For a compressed file in the response:
Cache-Control	max-age=2592000
Connection	keep-alive
Content-Encoding	gzip
Content-Length	44291
Content-Type	application/x-javascript; charset=utf-8
Date	Sun, 20 Dec 2015 10:21:39 GMT
Etag	"567668c6-ad03"
Expires	Tue, 19 Jan 2016 10:21:39 GMT
Keep-Alive timeout=5
Last-Modified	Sun, 20 Dec 2015 08:37:26 GMT
Server	nginx
Vary	Accept-Encoding

But Firefox writes that it took 73 ms to get the file.
Can you tell me why this behavior is observed? How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav Skillz, 2015-12-20
@vlskillz

Hello, I drank all the questions after this article .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question