I just read the de facto standard for HTML5 offline/localStorage.
It has me curious: if I build my web app to work regardless of whether or not there’s an internet connection, and I use HTML5 localStorage to do this, then how are web app URLs affected when in “offline mode”?
For instance, normally my web app’s home page might be http://myapp.example.com
. How would this change in offline mode; what would the URL be?
I’m hoping that the browser would allow my users to still go to http://myapp.example.com
, but then detect no network connection, and attempt to load the site from localStorage.
But it’s also possible that, once they load the site from cache, they automatically change the URL to something like file:///path/to/localStorage/homepage.html
.
It’s also entirely possible I misunderstood that entire article and this is not something that even localStorage
can do for me. Any ideas?
localStorage
is just a storage location that your web app can access, you still need internet access for everything else unless it has been cached already by the browser.
here’s some info I dug up about localStorage
:
localStorage
doesn’t change the url of your resources to local files, those are still stored in your server or your browser cache.- you have to access
localStorage
manually to access the stuff you stored. you do that like solocalStorage.getItem('key')
from that, you have to manually code a check to see if you already have the resources you need in localStorage
, if not then download it from the server via ajax or whatever you prefer
7