nginx status code 200 and 304

21,003

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;
    break;

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

Share:
21,003

Related videos on Youtube

Chamnap
Author by

Chamnap

Updated on September 18, 2022

Comments

  • Chamnap
    Chamnap almost 2 years

    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;
            break;
        }
    }
    

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