gpt4 book ai didi

python - Flask - 为我的外部 .css 文件获取 304 状态

转载 作者:行者123 更新时间:2023-11-28 22:30:00 24 4
gpt4 key购买 nike

我正在构建一个网络应用程序。在我的元素目录中工作的所有外部链接之前工作正常,但我注意到昨天每次修改 .css 文件时它根本没有呈现此更改。它实际上以相同的样式卡住,无论我是否删除整个 .css 文件内容。

这是我在运行 flask 时得到的响应:

 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger pin code: 230-950-485
127.0.0.1 - - [09/Mar/2017 17:53:09] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [09/Mar/2017 17:53:10] "GET /static/css/main.css HTTP/1.1" 200 -
127.0.0.1 - - [09/Mar/2017 17:53:10] "GET /static/js/main.js HTTP/1.1" 200 -
127.0.0.1 - - [09/Mar/2017 17:53:10] "GET /static/css/main.css HTTP/1.1" 304 -
127.0.0.1 - - [09/Mar/2017 17:53:14] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [09/Mar/2017 17:54:04] "GET / HTTP/1.1" 200 -

请注意 304,似乎这可能是问题所在?我很感激关于采取什么步骤的任何建议。

最佳答案

在 Flask 中这很常见,无论您使用内部文件还是外部文件:

HTTP 响应

304 NOT MODIFIED

A conditional GET or HEAD request has been received and would have resulted in a 200 OK response if it were not for the fact that the condition evaluated to false.

In other words, there is no need for the server to transfer a representation of the target resource because the request indicates that the client, which made the request conditional, already has a valid representation; the server is therefore redirecting the client to make use of that stored representation as if it were the payload of a 200 OK response.

这意味着 Flask 告诉浏览器它已经有了内容。

如果您清除浏览器缓存,您会注意到 Flask 在您的下一个请求中返回 200。

关于python - Flask - 为我的外部 .css 文件获取 304 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42707215/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com