I have an image site set so that if an image is linked to directly (meaning if the referrer isn’t my site) then it redirects to the page that the image is on.
This works fine for FF and IE, but in Chrome and probably Safari, after the redirect the image doesn’t show up because the browser has already cached it as a redirect. Only after a refresh does it show up.
Any way around this?
Once a file is downloaded to a browser (and placed in its cache), there is nothing which you can do to prevent the browser from extracting it from its own cache.
With HTML (PHP, etc) files which render as a page, it’s a simple matter to include expiry data IN THE SCRIPT. With images, that’s just not possible.
I thought about that, but I didn’t like the inconsistency of having a different file name each time. As long as it works (does anybody know if browsers don’t just ignore the extra stuff at the end?), then I suppose I’ll go with it.
Use random parameter to the file name on the page.
<img src="image.png?123321" />