0
我有開始這樣一個web應用程序:刪除瓶內存緩存
#It starts here
@app.route('/game')
def game():
裏面game
,它動態地構建一個圖像與PIL
並將其保存到/static/testing_image.png
那麼它呈現的模板。
return render_template('game.html',
file_name=file_name,
image_width=SQ_SIZE,
sleep_time=1000
)
現在,裏面game.html
,什麼情況是,我等sleep_time
毫秒,然後我想去再打電話game
,從而使新圖像的生成和顯示。
下面的代碼會等待圖像完全加載後顯示,等待和重定向。
function LoadImage() {
var img = new Image(),
x = document.getElementById("image");
img.onload = function() {
x.src = img.src;
var sleep_time={{sleep_time}};
setTimeout(function(){
//I REDIRECT HERE
window.location="{{url_for('game')}}";
}, sleep_time);
};
img.src="{{url_for('static', filename=file_name) }}";
}
的問題
問題當然是將圖像從內存緩存提供的,即使底層文件,/static/testing_image.png
,已經被更新,燒瓶沒有得到新的一。
您可以在下面看到testing_image.png
從緩存中。
我的問題是雙重的。
- 我應該以不同的方式做到這一點?
- 如果不是,我該如何強制燒瓶在圖像上重新加載?
嗯,這是本質上是調用自身的模板。我只是想在第一個調用之後進行調用,而不是在緩存上保存任何內容。 – elelias