from flask import Flask
from flask import render_template
app = Flask(__name__)
app.config["TEMPLATES_AUTO_RELOAD"] = True
@app.route("/")
def index():
return render_template("index.html")
@app.route("/hello/<name>")
def hello(name):
return render_template("hello.html", name = name)
if (__name__ == "__main__"):
app.run(debug = True)
So in order to see the most up to date css I have to hold shift and then refresh. Obviously, this isn't ideal, I want the user to see the most up-to-date version automatically. I was told that the config line would od that, but it isn't working properly. How do I actually get this to work?
CodePudding user response:
This has more to do with the browser cache than with flask it self. So what you can do is modify your css files names every time you modify them. So you say is way too much work?
Well there is a flask extension called Flask Static Digest that will keep track of your static files (You can config what it keeps track of) and will compile them with an md5 tag dependig on the files content. So every time you update statics files and compile, the names of the files will change as well and the browser will be forced to reload the resources.