PHP – Prevent GIF image loaded from browser cache

I would like to show a GIF image on a website but i found that the animation is not working as the browser caches the GIF image after first load. Here is a PHP workaround by adding the current timestamp to the image src url.

<img src="https://eureka.ykyuen.info/example.gif?v=<?php echo Date("Y.m.d.G.i.s"); ?>" />

 

Done =)

Reference: cache woes, how to force an image to refresh or load fresh

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.