10.6. Caching

If the accessed data is not changing during the course of its reuse it always makes sense to cache it. Caching is a time-tested way of increasing performance by avoiding data fetches across the network and using pre-fetched local data instead.

Caching emerged in the world of databases and operating system file access and became a popular technique in web applications. Most browsers today cache content that promises to be idempotent and rarely changing. Therefore, a web site's static content and images are often fetched from cache after the first time, when they are loaded. Browsers also define a cache expiration policy to make sure content does not reside for periods beyond which its usefulness is questionable, becoming stale.

A Flex application runs in a browser and delegates all its web user agent responsibilities to the browser. Therefore, all HTTP requests that involve the GET method are, by default, cached on the user's disk. Only in situations where the browser cache is turned off or the HTML wrapper page explicitly defines <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> head tag is the caching not available.

Sometimes, the caching facility also has a notorious side effect, when calls to remote destinations for data involve GET method calls. Subsequent calls to the data fetch remote URI using the GET method are served from the cache and a trip to the remote destination is skipped. This is sometimes a problem as the application data may be stale. A small ...

Get Professional BlazeDS: Creating Rich Internet Applications with Flex® and Java® now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.