How to force the browser not to cache images

When I made my website, I ran into a big problem: because I often make modifications to my games and also change the visual theme, I have to update the images. However, the browser continues to show the old images, even if I overwrite the image files (due to the browser cache).

I did a search on the web, and the solution is simple: just append a code after the filename (for example the timestamp). Example:

But appending the code manually on each image is rather uncomfortable; moreover, when you change an image, you have to update the timestamp manually.

This script solves the problem: it automatically appends the timestamps on all images and also on links. It uses the PHP DOM extension to find images and links, then it modifies the attributes src and srcset for images, href for links.

Just include the script manipulate1.php before the html tag, manipulate2.php after the html closing tag. Enjoy!