Why is Flask ignoring Cache-Control? Why is Flask ignoring Cache-Control? flask flask

Why is Flask ignoring Cache-Control?


This right way to set cache-control for your case is:

@app.after_requestdef add_header(r):    r.headers["Cache-Control"]  = "no-store max-age=0"    return r

no-store will only prevent new resource from being cached, but it will not prevent the cache from responding with a resource from an earlier request. Setting max-age=0 will force the cache to revalidate.

Also, setting cache-control the following way is a bad way to achieve this, and that's why it didn't work:

r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, public, max-age=0'"