When my Flash project downloads remote assets, I would like to use the browser cache to save bandwidth. But if that asset has been updated, I would like the updated version to be downloaded one time and replace the cache so that the next time it is needed, the updated cache version is used instead. Is this possible?
Currently, I'm checking to see if the CRC of the downloaded asset matches. If it doesn't, I do that trick to prevent caching by adding "?" + Math.random()*10000
to the end of the URL. But the problem is that means the file will never be cached, until the user empties their browser cache, correct?
Let's say the first version of the file located at www.myWebsite.com/myAsset
has a CRC of 0x00000001
. The first time my Flash is played, it downloads myAsset and it goes in the browser cache. The next few times my Flash is played, bandwidth is saved because myAsset is pulled from the cache.
But then I upload a new version of myAsset which has a CRC of 0x00000002
. The next time my Flash is played, it first tries the old cache of www.myWebsite.com/myAsset
, but sees that the CRC doesn't match, so it redownloads the file as www.myWebsite.com/myAsset?81234
. The problem is this redownload will continue to happen every time my Flash is played because, the 0x00000001
version in the cache will never match the new version, effectively defeating the purpose of caching.
Is there a way to update the cache of www.myWebsite.com/myAsset
with the new 0x00000002
version?
User contributions licensed under CC BY-SA 3.0