I am using following code to cache my static files on my flask app which is hosted on heroku:
# cache control
@app.after_request
def add_header(response):
# rule so it will only affect static files
rule = request.path
if "static" in rule:
response.cache_control.max_age = 1000000
return response
else:
return response
It works fine.
But now I made some changes and I need that the site loads the new files. If I open the site in regular browser where I already opened it, it loads the old files (because they are cached).
In incognito mode or hitting ctrl+f5 = loads the new files. The problem is a regular user wont hit ctrl+f5 or use incognito mode.