D
D
Dima_kras2019-01-21 17:41:47
Python
Dima_kras, 2019-01-21 17:41:47

How can I prevent the browser from taking an image from the cache?

Good afternoon, there is an image server for internal use, on request - it gives out the n-th image from the directory:
Server code:

@app.route('/get_image')
def get_image():
    n_img = int(request.args.get('n_img'))
    file_name = get_file_n(n_img)
    return send_file(file_name, mimetype='image/jpg')

To view the picture, I use the html page on which the picture is shown, the page code:
<img src="http://192.168.1.13:49001/get_image?n_img=1">

When opening a page in a browser, a "fresh" image from the server is not always requested.
To request a fresh picture, you need to open an incognito window, which is not convenient.
Even ctrl+f5 doesn't always help.
The question is how to prevent the browser from caching an image on a specific html page?
Well, or how to "deceive" the browser so that it thinks that this is a new picture every time and loads it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bbkmzzzz, 2019-01-21
@bbkmzzzz

You can try adding the header Cache-Control: no-cache, no-store, max-age=0 to the response

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question