I have implemented application caching in a web app for the iPhone, and it seems to work, both on mobile Safari and and on my desktop iMac.
Using iOS4, Safari 5.0, MacOS X 10.6.4.
I am using the Webkit developer tools in Safari to debug it.
What is bugging me at the moment is that when I go enable the debugger and run it, the debugger console reports an error:
"Failed to load resource: The URL can’t be shown callButton24C.png"
The png file is one I use in the App, or at least that one was one I used. I could not pin down what part of my code was triggering the error.
Initially I got errors about a number of resource files because I was pointing at the wrong directory. I am using relative url's, and I had just cleaned-up my folder layout which among other things involved moving the main html file to the top level of the app folder, which required changing the image urls from "../Images/...开发者_开发技巧" to "Images/..." in the my .js file and the html file, and all was well.
This all got sorted out, but I started noticing the above error persisting, even tho the app seemed to work ok - I had got that or related error complaints as I worked thru sorting out the urls which needed adjusting after my folder re-arrangement.
I tried duplicating the app folder and running it from there - same thing.
Then I made a small change to the name of the file and to all the url's pointing to it, and after working thru the cache update process, got it all working again, but I still got the same message, with old image file name.
I do a search thru all the files in the folder for any references to the old name - nothing.
I told Safari to clear its cache. Still get the error message.
Could this be in the application cache? Is there some way to positively clear it?
The app seems to be working, but I would like to know what is going on. Can I safely ignore the message, or does it indicate something which might trip me up at soem time?
6.6.7 Expiring application caches
As a general rule, user agents should not expire application caches, except on request from the user, or after having been left unused for an extended period of time.
Application caches and cookies have similar implications with respect to privacy (e.g. if the site can identify the user when providing the cache, it can store data in the cache that can be used for cookie resurrection). Implementors are therefore encouraged to expose application caches in a manner related to HTTP cookies, allowing caches to be expunged together with cookies and other origin-specific data.
For example, a user agent could have a "delete site-specific data" feature that clears all cookies, application caches, local storage, databases, etc, from an origin all at once.
精彩评论