Flask css not updating [closed]

Problem is, as already said, related to browser cache.

To solve that, you could add some dynamic variable to your static (css, js) links. I prefer last modified timestamp for each file.

/static/css/style.css?q=1280549780

Here is a snippet for that:

http://flask.pocoo.org/snippets/40/

@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)

Leave a Comment