Answer the question
In order to leave comments, you need to log in
How to defeat the browser cache after loading a new image?
Hello! The user uploads an avatar via ajax, while the file name on the server does not change. How, in this case, to make sure that after replacing the image, it is taken not from the cache, but from the server?
Answer the question
In order to leave comments, you need to log in
Append random numbers to the end of the filename.
img.png?352637362
Dynamically
change the contents of src img to a new url, you can even change the entire img tag using innerHTML
You still have to change the path to the image. for example, it is good practice to write in the form img/avatar.png?ver-2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question