flask的nocache防止js不刷新
Method 1: @app.route('/nocache') def something_not_cached(): resp = make_response(render_template(...)) resp.cache_control.no_cache = True return resp Or you write a decorator: @app.route('/nocache') @nocache def something_not_cached(): return render_template(...) And here is the decorator: from flask import make_response from functools import update_wrapper def nocache(f): def new_func(*args, **kwargs): resp = make_response(f(*args, **kwargs)) resp.cache_control.no_cache = True return resp return update_wrapper(new_func, f) resp.cache_control is an accessor for the Cache-Control header, you can also modify the header directly: resp.headers['Cache-Control'] = 'no-cache'