| Previous | Next | |
Windows: Not Applicable
Macintosh: Flash 8 or 9 AS2.0 SWF + mProjector
2.0;
mApplication.enableCaching(enable:Boolean) : Voidenable - true or false
Nothing.
Method; Enables or disables Macintosh URL caching.
Caching is off by default (version 2.0.3 or later) every time your Mac mProjector application starts up. In order to have no caching, call mApplication.enableCaching(false).
If you just want to clear the cache, call mApplication.enableCaching(false), and then immediately mApplication.enableCaching(true).
The preferred solution for caching problems is to either:1) have your server reply with an "expires" header when serving the file or 2) append a random number parameter to your URL making it unique and thus loading the older cached file.
If neither of these options works for you situation, use the mApplication.enableCaching() command.
With caching on, the following happens when you ask for a URL (which happens when you LoadVariables, or use XML calls with URLS, etc.):
a.) The cache is checked to see if the exact same URL has been previously loaded. If it has, and if the time in the "Expires: " header of the cached copy is in the future, then the cached copy is returned, and no internet transaction takes place.
b.) If there is no cached copy, or if the "Expires: " header of the cached copy is in the past, then the cached copy is deleted, and an attempt is made to load the file from the net.
c.) If the attempt fails, no cached copy is kept, and an error is returned.
d.) If the attempt succeeds, the headers of the retrieved file are examined.
i.) If there is a valid "Expires: " header, the file will be cached.
ii.) If there is no "Expires: " header, but there is a "Content-Length: " header, then an "Expires: " header is computed for two hours hence, and the file is cached.
iii.) If there is neither an "Expires: " header, nor a "Content-Length: " header, then the file is not cached.
The file is passed through to your SWF during this read from the internet, whether it is cached for the future or not.
In all cases, headers are stripped from the transaction before the contents are passed through to your SWF.
As a result of the above, XML files generated by PHP scripts (which should come back lacking both headers) should not be cached. This is the preferred way to supply XML which changes often. Generating your XML
from PERL should be equally easy, and should also generate XML which is not cached (because it lacks both an "Expires: " and a "Content-Length: " header)
Many servers automatically generate "Content-Length: " headers for many files (those that are not being generated on the fly, like .txt, .jpg, .gif, etc.) In order to prevent XML files which are statically generated from being cached, you should supply "Expires: " headers which contain dates from the past. How to do so is server dependent, and may not be easy. We recommend using PHP or PERL to generate XML on the fly, or turning caching off.
Note:
"Expires: " headers must be in RFC1123 time format, for instance "Expires: Tue, 08 Oct 1996 08:00:00 GMT"
For more information about caching on the web, please see:
http://www.web-caching.com/mnot_tutorial/how.html
But note that we do not examine the multitude of possible headers mentioned in the article; our scheme works only as above.
This example clears the cache.
mApplication.enableCaching(false); mApplication.enableCaching(true);
| Questions or Feedback? | Previous | Next |