diff --git a/doc/howtouseappcache.md b/doc/howtouseappcache.md index 2347d41..435a39c 100644 --- a/doc/howtouseappcache.md +++ b/doc/howtouseappcache.md @@ -1,9 +1,11 @@ Tips on using application cache =============================== +[UPDATED: Aug. 6, 2015] + If you have a requirement to reload your application or restart the browser while offline then you will need to use the [application cache](http://appcachefacts.info/). Some developers also use application caches to speed up page reload performance. For example, Google uses an application cache when load their main web page. -The application cache, also sometimes referred to as the 'manifest file', will allow you to store any file that is required for offline use. The list of acceptable files that you can store includes html, JavaScript libraries, CSS and images. Any file that your application requires to run normally will have to be referenced in the application cache. This is not to be confused with the Local Storage API. +The application cache, also sometimes referred to as the 'manifest file' or 'cache manifest', will allow you to store any file that is required for offline use. The list of acceptable files that you can store includes html, JavaScript libraries, CSS and images. Any file that your application requires to run normally will have to be referenced in the application cache. This is not to be confused with the Local Storage API. Once an application and its associated files are stored in the application cache it will be available from the cache the next time an application restarts. @@ -22,22 +24,66 @@ NOTE: You cannot use the regular CDN for the ArcGIS API for JavaScript because t ``` -**Step 4** Be sure to include and use the `/utils/appCacheManager.js` library as a module in your application. This will enable you to monitor what's going on in the application cache and capture specific events. For example if you want to know when the cache file has completely finalized its loading process then you can listen for the CACHE_LOADED event. Here is a psuedo code example of how to instantiate it: +**Step 4** + +For debugging purposes make sure the following script is included as close to the top of the
section as possible: ```js - appCacheManager = new AppCacheManager(true,true); - appCacheManager.on(appCacheManager.CACHE_EVENT,cacheEventHandler); - appCacheManager.on(appCacheManager.CACHE_ERROR,cacheErrorHandler); - appCacheManager.on(appCacheManager.CACHE_LOADED,cacheLoadedHandler); + ``` -In the `/samples` directory there are two examples, `appcache-features.html` and `appcache-tiles.html` that demonstrate how to use tiles, features and the appCacheManager with the application cache. - ### IMPORTANT Usage Tips -The application cache isn't ready until the `CACHE_LOADED` event fires. After that event a user can safely take the application offline. Sometimes files can load very slowwwwwly, and sometimes they can timeout. Be sure to take this into account. +You'll need to pay attention to the various events associated with the application Cache. The `noupdate` event means the cache doesn't need to be updated. The `cached` event means that a new update has finished loading. After these events a user can safely take the application offline. + +NOTE: Sometimes files can load very slowwwwwly, and sometimes they can timeout. Be sure to take this into account. If ANY file specified in the application cache fails to load for any reason, then the entire load will be rejected by the browser. The entire application cache will fail to load and no files will from the loading process will be cached. @@ -53,7 +99,7 @@ Too large of an application can cause a mobile browser to run slugglishly or cra * Note, you can also increase the amount of storage here by checking 'Override automatic cache manage' and enter a new limit value. Or, type about:config in address bar > modify the value field for `browser.cache.disk.capacity`. * Note: firefox has a theoretical upper bound of [1GB](http://mxr.mozilla.org/mozilla-central/source/netwerk/cache/nsCacheService.cpp#607) and apparently a tested/verified(?) upper bound of [500MB](http://www.html5rocks.com/en/tutorials/offline/quota-research/) on Android. -* Safari - Developer Tools > Show Web Inspector > Application Cache (click on the cookie crumbs at the top left of the console window). this won't give you the total size, but you can at least see what is in the cache and each objects size. +* Safari - Developer Tools > Show Page Resources > Application Cache (click on the cookie crumbs at the top left of the console window). ###Configuring your web server @@ -71,7 +117,7 @@ In Chrome you can navigate to chrome://appcache-internals/ then select the appro In Safari iPhone and iPad go to settings and select "Clear Cookies and Data." -Safari on desktop can be alot more tricky. Simply attempting Develop > Empty Caches may not work. On a Mac you will have to: close your browser, manually delete the .db file by going to /