简体   繁体   中英

Status code 304 (Jade, Node, Express)

I'm linking bootstrap and jquery in my jade file,

link(rel='stylesheet', href='/stylesheets/bootstrap.css')

and

script(src='/javascripts/jquery-3.1.1.js')
script(src='/javascripts/bootstrap.js')

This Jade file is in my views folder. The boostrap css is in my public/stylesheets folder and the javascript is in the public/javascripts folder.

When I run my application using nodemon, it says

GET / 200 80ms - 1.65kb
GET /stylesheets/bootstrap.css 304 1ms
GET /javascripts/jquery-3.1.1.js 304 3
GET /javascripts/bootstrap.js 304 2ms

The javascript and css files do not load up.

Suggestions?

304 Not Modified

If the client has performed a conditional GET request and access is allowed, but the document has not been modified, the server SHOULD respond with this status code. The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.

Server sent 304 http status to the client (browser) to let it know the file is not modified since the browser last received the copy of the file with 200 status code. When this happens, usually browser should have cached copy of the files and will load the same from the cache .

Better, clear all your browser cache by deleting all temporary files, histories etc and close and reopen (restart) your browser.

Reload the page and check the status code again in nodemon . It should be 200 this time.

To get rid of this status completely you can add header

res.header('Cache-Control', 'no-cache, no-store, must-revalidate')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM