Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using nginx + passenger. I'm trying to understand the nginx response 200 and 304. What does this both means? Sometimes, it responses back in 304 and others only 200. Reading the YUI blog, it seems browser needs the header "Last-Modified" to verify with the server. I'm wondering why the browser need to verify the last modified date. Here is my nginx configuration:

location / {
    root /var/www/placexpert/public;   # <--- be sure to point to 'public'!
    passenger_enabled on;
    rack_env development;
    passenger_use_global_queue on;

    if ($request_filename ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|swf)$) {
        expires max;

How would I add the header "Last-Modified" to the static files? Which value should I set?

share|improve this question

HTTP 200 code means that the document/request has been found and served/completed successfully (as opposed to 302 (found) or 404 where the document was not found).

HTTP 304 means that the data was not modified, therefore the cached version on your machine has been used to save downloading it from the server again. This is usually static files when using nginx and seems to be the case in your example due to this section of the config:

if ($request_filename ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|swf)$) {
    expires max;

You have set an expire time of max on those sort of filetypes, so it will not redownload them.

share|improve this answer

I'm not very familiar with nginx but I think that the browser needs this header to decide if the result needs to be renewed. Why not just add this header to the server's reply?

add_header  Last-Modified: $date_gmt;

I've tried it and got the header:

$ netcat 80
GET / HTTP/1.0
HTTP/1.1 200 OK
Server: nginx/1.0.0
Date: Wed, 27 Apr 2011 10:23:19 GMT
Content-Type: text/html
Content-Length: 151
Last-Modified: Thu, 21 Apr 2011 17:43:42 GMT
Connection: close
Last-Modified:: 1303899799
Accept-Ranges: bytes
. . . 
share|improve this answer
That Last-Modified header is not in correct format. – Palimondo Jan 17 '12 at 3:56

Your Answer


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.