AJAX - The Complete Reference

(avery) #1

PART II


Chapter 6: Networking Considerations 275


For complete cache management there is a public method AjaxTCR.comm.cache.
remove(key), which can remove the item specified by the key passed. There is also an
AjaxTCR.comm.cache.getAll() method that simply returns the entire cache, as well as
a AjaxTCR.comm.cache.clear() method to clear the cache.
To demonstrate the custom cache, the example found at http://ajaxref.com/ch6/
customcache.html can be used to exercise its various features. Figure 6-21 shows a couple of
requests made to show the process. If you want to exercise a number of features and study
the cache activity, an “autorun” button will do that for you.

Precaching


Another method to improve performance, called precaching or prefetching, entails downloading
objects ahead of time if they are likely to be used. Typically, the download can happen during
page idle time. Some browsers, such as Firefox, actually have a prefetching mechanism built-
in, which is easily configured using the <link> tag. For example, here we specify to fetch an
image called big.jpg

<link rel="prefetch" href="/ch5/big.jpg" />

FIGURE 6-21 A custom Ajax cache in action
Free download pdf