0

I'm working on a Flash browser game that will download large amounts of external MP3s through the use of URLRequest. I want to cache those MP3s on the user's computer so they don't get re-downloaded every time the user plays the game in order to save some server bandwidth.

I could use SharedObject or FileReference, but both require user interaction at some point. If the SharedObject exceeds a certain size, a popup appears asking the user for permission to increase the size. And with FileReference, the user has to confirm saving the file. Is there any way to do it without requiring any interaction from the user? It seems there is a way with AIR, but I don't want to go that route.

edit: I've done some testing, and the browser does not seem to cache things. I uploaded a webpage and test Flash, which loads an external 4 MB MP3 file and displays a progress bar. The first time I opened the page in my browser, I let it load normally. Then I navigated away from that page, used Net Limiter to limit my download speed to 5 KB/s, and went back to my test page. If the browser did in fact cache it, the MP3 should have immediately completed downloading, but instead it started at 0% and filled very slowly to 100%. I also tried the reload button, opening the test page in a new tab, and restarting the browser, but with the same results. I tried this with Chrome and IE11.

edit2: It seems file caching settings are set server side. My test server was a free webhost. It doesn't seem like I can alter those settings.

BladePoint
  • 632
  • 5
  • 16
  • 1
    Stream? If you use regular files the browser will cache them. – moot Feb 10 '15 at 05:10
  • If I use URLLoader/URLRequest on MP3 files, the browser will cache them? – BladePoint Feb 10 '15 at 06:52
  • 1
    yes, it will, browser caches all http requests, _Loader_ for swf/images as well – fsbmain Feb 10 '15 at 10:21
  • 1
    Browser will cache files and do the job for you, you have just to configure the cache period of your files in server side. – akmozo Feb 10 '15 at 13:21
  • If you can't use AIR then you will have no control over the cache behavior. – BotMaster Feb 10 '15 at 14:05
  • 1
    Yes, use mp3s and they'll get cached by the browser. Browser cache works well. Just make sure you're using the same url for the mp3s. Any change in the url, variables included, and you get new copy not cached. – moot Feb 10 '15 at 16:51
  • I uploaded a webpage and test Flash, which loads an external 4 MB MP3 file with a progress bar. The 1st time I opened the page in my browser, I let it load normally. Then I navigated away from that page, used Net Limiter to limit my download speed to 5 KB/s, and went back to my test page. If the browser did in fact cache it, the MP3 should have immediately completed downloading, but instead it started at 0% and filled very slowly to 100%. I also tried the reload button, opening the test page in a new tab, and restarting the browser, but with the same results. I tried this with Chrome and IE11. – BladePoint Mar 25 '16 at 08:20

0 Answers0