0

I have a basic question regarding Python and Flask for web development.

In my html template file, I have a line to display an image, shown as below:

<img width="600" height="451" src="static/graph_1.png">

The image is in the static folder. When I update this image but using the same name 'graph_1.png", the web still shows the old image, not the updated one. I think the browser somehow remembers the old image with the same name. But I didn't really want to change the name of the image. I learned it has something to do with "Catche-Control"? Please advice on how I can solve this problem. Thanks in advance!

1 Answer 1

1

User cmd+shft+r on mac or ctrl+shift+r on a pc to load the page without using cache.

off topic, but you might want to look into the flask documentation on templates. A better approach to adding the path to the html is using jinja to inject the path. The nice thing about this is if you ever change the file structure, as long as the file name remains the same you're golden!

<img width="600" height="451" src="{{ url_for('static', filename='graph_1.png' }}>

You can find more info here

Sign up to request clarification or add additional context in comments.

1 Comment

I typically view the page in incognito mode in chrome, which doesn't store browsing history and cache beyond the instance, but you still need to do a full refresh as described on updates unless you close and reopen the window. There might be some other solution, but I've just got used to the cmd+shft+r refresh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.