简体   繁体   English

状态码304(Jade,Node,Express)

[英]Status code 304 (Jade, Node, Express)

I'm linking bootstrap and jquery in my jade file, 我在我的玉文件中链接bootstrap和jquery,

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. 这个Jade文件在我的views文件夹中。 The boostrap css is in my public/stylesheets folder and the javascript is in the public/javascripts folder. boostrap css位于我的public / stylesheets文件夹中,javascript位于public / javascripts文件夹中。

When I run my application using nodemon, it says 当我使用nodemon运行我的应用程序时,它说

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. javascript和css文件无法加载。

Suggestions? 建议?

304 Not Modified 304未修改

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. 如果客户端已执行条件GET请求并允许访问,但文档尚未修改,则服务器应该响应此状态代码。 The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields. 304响应必须不包含消息体,因此总是在头字段之后的第一个空行终止。

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. 服务器向客户端(浏览器)发送304 http状态,以使其知道该文件未被修改,因为浏览器上次收到具有200状态代码的文件副本。 When this happens, usually browser should have cached copy of the files and will load the same from the cache . 发生这种情况时,通常浏览器应该有cached copy的文件cached copy ,并从cache加载相同的文件。

Better, clear all your browser cache by deleting all temporary files, histories etc and close and reopen (restart) your browser. 更好的是,通过删除所有临时文件,历史记录等清除所有浏览器cache ,然后关闭并重新打开(重新启动)浏览器。

Reload the page and check the status code again in nodemon . 重新加载页面并在nodemon再次检查状态代码。 It should be 200 this time. 这次应该是200

To get rid of this status completely you can add header 要完全摆脱这种状态,您可以添加标题

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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