Status code 304 (Jade, Node, Express)

蓝咒 提交于 2019-12-07 17:24:59

问题


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?


回答1:


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.




回答2:


To get rid of this status completely you can add header

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



来源:https://stackoverflow.com/questions/40582895/status-code-304-jade-node-express

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!