如前所述,问题与浏览器缓存有关。
为了解决这个问题,你可以向静态(css,js)链接中添加一些动态变量。我更喜欢每个文件的上次修改时间戳。
/static/css/style.css?q=1280549780
这是一个片段:
http://flask.pocoo.org/snippets/40/
@app.context_processordef 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)


