Disabling caching in Flask

后端 未结 4 1691
执念已碎
执念已碎 2020-11-30 01:27

I have some caching issues. I\'m running very small web-application which reads one frame, saves it to the disk and then shows it in browsers window.

I know, it is p

4条回答
  •  天涯浪人
    2020-11-30 02:06

    OK,

    finally it worked with this:

    @app.after_request
    def add_header(r):
        """
        Add headers to both force latest IE rendering engine or Chrome Frame,
        and also to cache the rendered page for 10 minutes.
        """
        r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
        r.headers["Pragma"] = "no-cache"
        r.headers["Expires"] = "0"
        r.headers['Cache-Control'] = 'public, max-age=0'
        return r
    

    If you add this, this function will called after each request done. Please,see here

    I would be happy, if anyone could explain me why this headers overwriting did not work from the page handler?

    Thank you.

提交回复
热议问题