Flex Pasta » Firefox SWF Cache
Firefox SWF Cache
If you use Firefox for Flex development, you may have had problems with a SWF caching problem. Even though a Flex compile updates the SWF file on the file system, Firefox doesn’t pull the new SWF from the server, but rather uses its internal already cached SWF file. This can cause headaches when trying to guess why the code change doesn’t appear in the browser. To solution has been to clear the cache in Firefox and reload the page. I turned my browser cache size limit down to 0MB. This doesn’t seem to fix the problem either. There is another setting that can’t be found in the Firefox interface.
- Open a new tab in Firefox.
- Type about:config in the url.
- Agree to the warning.
- Change the property browser.cache.disk.enable and set it to false.
Thus far this solution seems to keep my SWF file from being cached by Firefox.
22 Comments
1. [ UIBuzz ] » Blog A&hellip replies at 24th November 2008, 10:52 pm :
[…] thanks to this post on Flex Pasta there is a very easy solution to the problem. A big thank you to Brian for uncovering a solution to […]
2. Firefox caching driving y&hellip replies at 24th November 2008, 10:53 pm :
[…] thanks to this post on Flex Pasta there is a very easy solution to the problem. A big thank you to Brian for uncovering a solution to […]
3. Michael Boucher replies at 25th November 2008, 2:41 am :
Great post, thanks for the hint. I didn’t know about the about:config feature in Firefox. I’d suggest looking into the Web Developer Toolbar for Firefox as well. It makes it much easier to enable/disable cache (as well as cookie, javascript, css, etc.) in Firefox with the click of a mouse. Also has some other really helpful features as well. Web Dev Toolbar, Firebug, XPath Checker and Arthropod are must have’s for any Flash/Flex work IMHO.
Keep the great posts coming!
4. Stop SWF’s Caching &hellip replies at 25th November 2008, 6:29 pm :
[…] Stop SWF’s caching in FireFox nuff said! Bookmark the permalink. Follow any comments here with the RSS feed for this post. Post a comment or leave a trackback: Trackback URL. « Efflex SWC available for download […]
5. Ben Goosman replies at 25th November 2008, 7:01 pm :
Another solution is the ctrl-f5 keyboard shortcut. It refreshes the page and tells Firefox not to use the cache.
http://support.mozilla.com/en-US/kb/Keyboard+shortcuts
6. Joeflash replies at 25th November 2008, 9:42 pm :
Or you can just append the following onto the end of the SWF filename, which has the added benefit that it will also solve the caching issue for anyone else viewing the file on their system:
?nocache=”+(new Date()).getTime()
You’ll have to add this in JavaScript either in your Flex index.template.html file or in the SWFObject code in the HTML page.
This is a tried and true hack that tricks the browser into thinking it’s accessing a new file, forcing it to get the file from the server each and every time, since this code returns the date plus the number of seconds elapsed in that day, which is as good as random.
When you’re ready for deployment, delete the code in your template or HTML page.
7. Joeflash replies at 25th November 2008, 9:44 pm :
Correction: it returns the number of milliseconds elapsed in that day, not the date plus num of seconds.
8. Brian Telintelo replies at 25th November 2008, 9:45 pm :
Very good idea, all though a hack I wish could be avoided!
9. Emad replies at 26th November 2008, 12:33 am :
It’s good, but easier way is CRTL + F5! This refresh page and load data from the source.
10. Demian Holmberg replies at 26th November 2008, 3:51 pm :
CTRL-F5 is a great idea, but it doesn’t always work. I had it fail in both IE and Firefox.
11. Why I’m not working&hellip replies at 29th November 2008, 5:04 am :
[…] Firefox SWF CacheStop Firefox caching swf files. I found this issue happening a lot when I upgraded to Firefox 3. […]
12. wt replies at 12th January 2009, 11:35 am :
Thanks for the solution, it works for me. So, if browser.cache.disk.enable is set to false, what else is kept from caching besides the swf files?
13. Bill replies at 31st January 2009, 10:44 am :
I think the hack (?nocache…) is a better solution. A user does not know when content has been updated to the server in order to press Ctl+F5 and get the new content.
14. Mark replies at 13th May 2009, 10:35 am :
Why do people keep posting ‘try CTRL-F5′? It’s like ‘wow dumba$$, I never thought of that.’ When you get past ‘Hello World’ and bouncing balls in your flash movies, then maybe you can sit at the table with the adults.
On a different note, I’ve tried all of the above solutions and the current version of Firefox refuses to refresh my swf. Any other ideas are welcome except the above mentioned. Thanks for the relevant info guys.
15. jsy replies at 15th June 2009, 11:51 pm :
perfect, thank you!
16. virgo_ct replies at 29th August 2009, 4:33 am :
Erm, this doesn’t seem syntactically correct:
?nocache=”+(new Date()).getTime()
The ” - is that supposed to be a “?
Also, if I use this in index.template.html, the line should look like this, right:
17. virgo_ct replies at 29th August 2009, 4:33 am :
value=”${swf}.swf?nocache=+(new Date()).getTime()”
18. McQuillen Interactive &ra&hellip replies at 4th September 2009, 5:47 pm :
[…] .swfs when I’d publish my Flex project in debug mode. I don’t know when or why this started but a short post from a fellow developer helped me solve this […]
19. DR replies at 15th December 2009, 4:00 pm :
Thanks for this…. it is (so far) finally doing the trick.
Regarding other comments - CTRL-F5 does not always work (in my experience it reloads the correct swf about 20% of the time in Firefox). Also, clearing the cache via web developer toolbar (or anything else) isn’t really workable since you have to do it every single time (which depending on what I’m doing can be several times a minute). Similarly, you can’t do the ?nocache= solution since Flex occasionally rebuilds the launch HTML file - overwriting that code….
20. Claude replies at 12th October 2010, 2:55 am :
value=”${swf}.swf?nocache=+(new Date()).getTime()”
Do I have to replace {swf} by the name of myy file? eg:
value=”${index}.swf?nocache=+(new Date()).getTime()”
21. it support replies at 1st April 2011, 4:38 am :
this doesn’t work for me. i tried clicking Tools->Clear recent history and selecting everything, i tried this tip and nothing. cached flash settings still won’t go away. i’ve confirmed on a different machine that my pictures have definately changed on the site, but i just can’t kill them off on this computer. i’m getting to the stage where i’m going to try creating a new user account just for this
22. Jason Bronson replies at 27th April 2011, 8:48 am :
The way that I do it is to hide the real swf name using apache rewrites.
Use a .htaccess file to handle random file names and then reference it using a dynamic render swf name in php or another language like this
In .php template….
nocache_.swf
Then use this .htaccess file
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^nocache_[0-9]+\.swf main.swf [NC]
This will then translate any url to main.swf behind the scenes
http://localhost/nocache_01.swf points to http://localhost/main.swf
http://localhost/nocache_02.swf points to http://localhost/main.swf
etc…
Leave a comment