[Python] Disabling caching in Flask [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 26, 2025.

  1. Stack

    Stack Membro Participativo

    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 probably not the best solution, but every time I save this read frame with the same name and therefor any browser will cache it.

    I tried to use html meta-tags - no success:

    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />


    Also, I have tried this one (flask-specific):

    resp.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
    resp.headers["Pragma"] = "no-cache"
    resp.headers["Expires"] = "0"


    This is how I tried to modify resp headers:

    r = make_response(render_template('video.html', video_info=video_info))

    r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
    r.headers["Pragma"] = "no-cache"
    r.headers["Expires"] = "0"


    Still both Google Chrome and Safari do caching.

    What might be the problem here?

    Continue reading...

Compartilhe esta Página