I have a small animated .gif that is set to only run one time. It appears on each page of a site. I’d like it to run as each page is opened, but I noticed it gets cached and so when navigating the site the animation doesn’t run again. Is there a way to force the animated .gif to play for each page?
try putting it in the master page layout as you would a logo
On Jan 1, 2011, at 2:33 PM, Mike Yenco wrote:
I have a small animated .gif that is set to only run one time. It
appears on each page of a site. I’d like it to run as each page is
opened, but I noticed it gets cached and so when navigating the
site the animation doesn’t run again. Is there a way to force the
animated .gif to play for each page?
Well, the definitive way to “bust” a cache is to add a querystring to
the image filename. You’ll have to resort to JavaScript for this, but
something like this might work:
Add an ID to your image (Item/Extended).
Apply Protaculous to the page, set to protototype-packed in the
Library picker.
Click on the top Function Body button, and paste in the following
code, taking care to replace the fake ID with your real one.
var img = $('item24');
var date = new Date();
img.src = (img.src + '?' + date.getTime());
That should give you a big long number after the question mark, which
should break any cache that the browser is giving you.
You could also do this in PHP, with the time() function, and some
markup to replace your image tag. This should be marginally faster
than the JavaScript, unless you are already running some Prototype
code on the same page anyway, in which case it will be a draw.