我有一個 html 檔案/templates/books.html,其中包含一個
<link rel="stylesheet" href="{{ url_for('static', filename="css/style.css") }}">
我有一個static/css/style.css包含以下代碼的檔案:
body {
}
所以什么都沒有。然后,我添加一種樣式:
body {
display: none;
}
它按預期作業。但是后來我再次洗掉了樣式,但是無論我更改了多少次,Flask 仍然不斷向我發送舊檔案等。
我嘗試了以下方法,但無濟于事:
- 重新啟動應用程式
- 重新啟動我的電腦
?v=1.0.0在檔案名的末尾添加類似的內容app.config('SEND_FILE_MAX_AGE_DEFAULT') = 0- 設定標題:
@app.after_request
def add_header(r):
r.headers["Cache-Control"] = "no-cache, no-store, must-
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
return r
- chrome devtools 中的“禁用快取”
- 使用 Ctrl F5、Shift F5、Ctrl Shift F5 等所有組合強制重新加載,也嘗試直接清除我的整個快取
- 不同的瀏覽器、隱身模式等
- 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" />
有誰知道我還應該嘗試什么?
uj5u.com熱心網友回復:
我嘗試通過制作一個最小的燒瓶專案來進行故障排除,但沒有遇到同樣的問題。然后我再次嘗試了我原來的專案,問題神奇地解決了。不知道為什么,但我會接受。我很欣賞這意味著這個問題對其他人沒有用,對此感到抱歉。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/361297.html
