Answer the question
In order to leave comments, you need to log in
How to update static/clear cache in browser with python-flask?
In general, I changed the pictures from my statics, and the browser shows the old ones.
A little earlier, I had another problem that the styles were not updated and I was offered to add the following code to the Flask file:
# SNIPPET FOR CAESH #
@app.context_processor
def override_url_for():
return dict(url_for=dated_url_for)
def dated_url_for(endpoint, **values):
if endpoint == 'static':
filename = values.get('filename', None)
if filename:
file_path = os.path.join(app.root_path,
endpoint, filename)
values['q'] = int(os.stat(file_path).st_mtime)
return url_for(endpoint, **values)
# SNIPPET FOR CAESH #
Answer the question
In order to leave comments, you need to log in
@app.after_request
def add_header(response):
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
response.headers['Cache-Control'] = 'public, max-age=0'
return response
Search is your friend. You can force pages to become outdated like this. Hint for puff, but adaptable at times.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question