When loading data, SWF files,or images from an external data source, some browsers may save the loaded object in the browser cache. This results in subsequent calls retrieving the cached item instead of the most recent item from the original source.

This can affect any class that loads data, images or SWF files. For example, in ActionScript 2.0, this can affect the LoadVars class and the XML class, as well as image and SWF loading via the Loader component or the movieClipLoader class.

In ActionScript 3.0, this can affect the following classes: XML, Loader, URLLoader, URLVariables, XMLDocument; and components which utilize these classes, such as ScrollPane.


To ensure that your SWF file always loads the most recent information from the original source, you can "trick" the SWF into thinking each loading action is unique.This is done by generating a random variable at the end of the action using a query string and Math.random. This forces Adobe Flash Player to internally "refresh" the data every time you load the data from the external source.

The following examples generate a random query string to avoid caching the variables:

loadVariables("mypage.asp?nocache=" + random(65000), 0, "POST"); myXML.load("path.xml" + "?" + Math.random() );

Additional Information

For more details about working with external data sources, see "Overview of Adobe Flash and database integration" (TechNote 14482). For information about preventing caching of SWF files, refer to "How to prevent caching of SWF files" (TechNote 14743).

Keywords: tn_15951

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy