V
V
vaniapooh2013-10-12 22:59:29
Nginx
vaniapooh, 2013-10-12 22:59:29

Nginx: Last-Modified in the Future

Now on my watch 23:50 Moscow time, October 12th. About an hour ago (at 22:58 Moscow time or 18:58 GMT) I posted an updated version of the site for production. When requesting a static file with the css extension from the server, Nginx receives the following headers:

HTTP/1.1 200 OK
Server: nginx/1.4.2
Date: Sat, 12 Oct 2013 18:58:05 GMT
Content-Type: application/x-javascript
Content-Length: 131157
Last-Modified: Sat, 12 Oct 2013 22:09:50 GMT
Connection: keep-alive
Vary: Accept-Encoding
ETag: "5259c8ae-20055"
Expires: Sat, 12 Oct 2013 19:28:05 GMT
Cache-Control: max-age=1800
Accept-Ranges: bytes


The server is caching with expires 30m, which can be seen from the difference between Date and Expires. At the same time, the date of the last modification of the file is shown at 22:09 GMT, but this is a date in the future (2 am October 13 Moscow time)!!! In fact, the file was modified at 22:09 Moscow time and then uploaded to the server. At the same time, the stat utility for the file gives the correct date:
Access: 2013-10-12 14:13:26.000000000 -0400
Modify: 2013-10-12 18:09:54.000000000 -0400
Change: 2013-10-12 14:13:26.000000000 -0400

Apparently due to the wrong date, the Expires header continues to be constantly updated, following the Date. The question is how to fix this behavior?

nginx settings:
        location ~* \.(jpg|png|gif|jpeg|css|js|doc|pdf|xls|docx|xlsx|odt|odc|ico)$ {
                root   /var/lib/tomcat7/webapps/ROOT;
                proxy_buffering           on;
                proxy_buffers 8 8k;
                proxy_cache static;
                proxy_cache_min_uses 1;
                proxy_cache_use_stale error timeout invalid_header http_500 http_502 http_503 http_504 updating;
                proxy_cache_valid 200 301 302 304 30m;
                expires 30m;
        }


Update 10/13/2013 10:50 AM: The date shown in Last-Modified has been reached by the server, but Expires still continues to be shown relative to Date, not relative to Last-Modified. Those. if i set expires 30m; - then each time a header is issued: Expires: Date + 30m;

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vaniaPooh, 2013-10-13
@vaniaPooh

The problem with Expires was solved by disabling all proxy directives and setting expires: modified +30m;

N
Nikolai Turnaviotov, 2013-10-13
@foxmuldercp

and on the web server (s) with dates and time zones everything is in order?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question