I have a Flash application that lets the user choose and upload a new avatar. However, since Flash seems to cache images, I keep seeing the old avatar long after the new one is successfully uploaded to the server and reloaded into the application. Is there any way to prevent this?
First, it’s not Flash, Flash activeX has no cache. It gets whatever it has to load from browser.
Possible workaround I can think of:
Retrieve your images from PHP/ASP(X) page that will send no-cache / need revalidate headers to browser together with images (not sure if it’ll help in all cases though).
Retrieve your images from PHP/ASP(X) page sending as part of request current time, this will make browser “think” the page tries to load new content, and not the cached.
I.e. your query may look like this when Flash asks server for an image:
[domain info]/getImage.php?imagename=someimage&requesttime=mm.dd.hh.mm
also, to make it easier on the server you can let Flash change the request only when it knows for sure there should be change. I.e. if you know the image didn’t have to change, save the last changed request somewhere in Flash and if you need to request it again - just use the last saved. This will load it from cache instead of calling your server page in vain =)