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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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