- From: <bugzilla@jessica.w3.org>
- Date: Tue, 15 Jan 2013 18:11:01 +0000
- To: public-html-bugzilla@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=20677 Bug ID: 20677 Summary: Unable to detect whether a file is in cache or not Classification: Unclassified Product: HTML.next Version: unspecified Hardware: All OS: All Status: NEW Severity: normal Priority: P2 Component: default Assignee: dave.null@w3.org Reporter: francois.remy.dev@outlook.com QA Contact: public-html-bugzilla@w3.org CC: mike@w3.org, robin@w3.org Some offline web applications need a way to detect whether a file is in cache or not. Currently, it's not possible to do so without downloading the file. Here are a few use cases where this ability would be useful: 1. Using an already cached version of the file if it's available, download the best version otherwise. // if we need a low-resolution image if(deviceToPixelRatio <= 1) { // if the high resolution image has already been downloaded if(applicationCache.isCached("./images/abc-123.2x.png")) { // use the high resolution image straightaway } else { // use or download a standard resolution image (faster) } } else { // use or download the high-resolution image } 2. Using an index it was already downloaded Let's suppose you have a list of scientific documents stored locally. The user types a query in to search the content of the documents. You want to help him find the results he want by expanding his query (ie: adding synonymous of the typed words as part of the query). You can do so by querying a third-party server that will give you the results based on a dictionary <http://syn.org/word/{WORD}>). However, the user may want to be able to use the functionality offline and download the dictionary <http://syn.org/all.json> as part of an appcache (this may result from an action done in another app using the same service which you don't know). If he does so, you want your application to use this dictionary directly and not issue a request to the server. We assume the CORS settings of the syn.org website are done so that you can access all data you need. if(dict) { task.done(dict[word]); } else if(applicationCache.isCached("http://syn.org/all.json")) { var xhr = ... xhr.open("GET", "http://syn.org/all.json", true) xhr.onload = function() { dict = xhr.response; task.done(dict[word]); } ... } else { var xhr = ... xhr.open("GET", "http://syn.org/word/"+encodeURIComponent(word), true) xhr.onload = function() { task.done(xhr.response); } } 3. Evaluating the time needed to make a feature available offline. Imagine a web application similar to Microsoft Excel. By default, the appcache will include the most basic features & function, and a bit of formatting (the rest is being done in the cloud). However, if an user want to edit graphics offline, it needs to download an API file for that. When the user if offline, you may want to know if the graphic library is available (=cached) or not in order to put the "insert graph" button in its disabled state otherwise. Now, the user return online because he really needed the graph library. The user want to see how many content will need to be downloaded if he want to "install" the graphing library for offline use the next time. If the Graphing library depends on some APIs used by more components, and that you want to say to user how many files will need to be dowloaded in order to make the functionnality available offline, you need to know how many of those components are already cached. You can either try to persist this yourself or rely on applicationCache.isCached(...) to get accurate results. -- You are receiving this mail because: You are the QA Contact for the bug.
Received on Tuesday, 15 January 2013 18:11:03 UTC