Purge client browser cache after deploying app to Heroku Purge client browser cache after deploying app to Heroku flask flask

Purge client browser cache after deploying app to Heroku


If you're using the same filenames it'll use a cached-copy so why not provide versioning on your static files using a filter? You don't have to change the filename at all. Although do read about the caveats in the link provided.

import osfrom some_app import app@app.template_filter('autoversion')def autoversion_filter(filename):  # determining fullpath might be project specific  fullpath = os.path.join('some_app/', filename[1:])  try:      timestamp = str(os.path.getmtime(fullpath))  except OSError:      return filename  newfilename = "{0}?v={1}".format(filename, timestamp)  return newfilename

Via https://ana-balica.github.io/2014/02/01/autoversioning-static-assets-in-flask/

“Don’t include a query string in the URL for static resources.” Itsays that most proxies will not cache static files with queryparameters. Consequently that will increase the bandwidth, since allthe resources will be downloaded on each request.

“To enable proxy caching for these resources, remove query stringsfrom references to static resources, and instead encode the parametersinto the file names themselves.” But this implies a slightly differentimplementation :)