Hacker News new | ask | show | jobs
by SapphireSun 3616 days ago
Here's an case study from an article I wrote on this topic that I never published:

Case Study 1: Google Maps and Offline Mode

Alice navigates her iPad to http://maps.google.com and looks up the geography of the city she lives in, Boston. Alice knows that she’s going to be traveling later that day and might not have access to WiFi, so she clicks the “Save for Offline” mode button that is either part of the browser or website interface.

The interface presents a permissions menu: “Maps will need to use 500MB of space and will add https://maps.google.com” to your offline hosts” Alice agrees and the download begins. Google Maps saves a copy of its client code, the necessary map data, and a light nodejs server implementation into a browser cache.

When the browser senses a connection has been lost, and Alice navigates to or is already on maps.google.com, the nodejs server spins up and requests are forwarded to that server. Alice notes that the browser indicates that the connection is offline and sets her expectations accordingly for what she’ll be able to do. When the connection is regained, the server shuts down and the browser forwards requests to maps.google.com’s true IP address.

One day Alice leaves the big city to go camping. She has downloaded maps of the campgrounds onto her iPad as is her usual practice. She moves into her cabin with her friends, and they all realize they have no connection and forgot to grab the maps. They have all brought their phones. Alice activates the promiscuous mode of google maps and the nodejs server becomes active on a mesh network and declares itself the secondary access point to the primary maps.google.com. The phones all mesh network with each other and the iPad. When one of her friends goes to maps.google.com, and looks up the camp grounds the phone asks the friend if she’d like to acquire a copy of the maps server from the iPad with a version number and date of acquisition. She agrees, and the phone downloads the copy of maps offline. As all the friends get the copy of maps offline, the servers distribute the requested map tiles using bittorrent.

The friends can now go explore the woods without depending on a single device (though they probably should have brought a paper map).