Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

caching - How to uncache static png after every flask run?

I have a single png file in my static folder that I update from each run and each time it is updated, it shows up in my webpage. However, no matter how many times I edit the png file, the edited version does not display on my webpage, and some older version does.

I have researched that this is a cache issue, but I cannot figure out how to empty the cache just of one png file.

It's driving me crazy.

Function that saves png file to static folder:

def plot_df(df, x, y, title="", xlabel='Date', ylabel='Tweets per date'):
    plt.figure()
    plt.bar(x, y)
    plt.gca().set(title=title, xlabel=xlabel, ylabel=ylabel)
    plt.savefig('static/timeseries.png') 

Accessing that file in html:

<h2 style="margin-top: 80px; margin-bottom: 20px; text-align: center;"><b>Time Series</b></h2>
<div style="text-align: center;">
    <img src="{{ url_for('static', filename='timeseries.png') }}" alt="" width="1000" height="700" style="border-radius: 20px; margin-bottom: 140px;">
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...