我有一些缓存问题.我正在运行非常小的Web应用程序,它读取一帧,将其保存到磁盘,然后在浏览器窗口中显示.
我知道,它可能不是最好的解决方案,但每次我保存这个相同名称的读取框架,因此任何浏览器都会缓存它.
我试图使用html元标记 - 没有成功:
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
Run Code Online (Sandbox Code Playgroud)
另外,我试过这个(烧瓶专用):
resp.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
resp.headers["Pragma"] = "no-cache"
resp.headers["Expires"] = "0"
Run Code Online (Sandbox Code Playgroud)
这是我尝试修改resp标头的方式:
r = make_response(render_template('video.html', video_info=video_info))
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
Run Code Online (Sandbox Code Playgroud)
Google Chrome和Safari仍然会进行缓存.
这可能是什么问题?
先感谢您
这是我的项目层次结构:
项目
这是我的HTML文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='custom.css') }}"/>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的.py烧瓶文件:
from flask import Flask, render_template, redirect, json, url_for, request, abort
from pymongo import MongoClient
client = MongoClient()
db = client.web_zoo
app = Flask(__name__)
@app.route('/')
def index():
return render_template('home.html')
if __name__ == "__main__":
app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)
我的CSS文件:
body {
color: green;
}
h1 {
color: orange;
}
Run Code Online (Sandbox Code Playgroud)
HTML和.py文件工作正常,HTML呈现并显示在页面上.然而,CSS不会改变.它只是以普通的黑色文字显示.
注意:所有这些导入都在那里,因为我正在做其他事情.我剥夺了其他一切,仍然有这个问题.
我可以链接bootstrap到它,CSS工作,但不是我自己的CSS文件.
我查看并尝试了以下解决方案: