New local storage options in HTML5 are sure to improve the performance of any applications that run in browsers.
TL;DR: With HTML5, you can now store as much as 5MB of data locally in the browser, and decide whether or not the data should persist when the browser session ends. Here’s a rundown of the HTML5 Web Storage options for app developers, as well as a few pitfalls you’ll want to avoid.
After years of fits and starts, the W3C’s final recommendation for the HTML5 specification was released in October 2014. Perhaps the greatest impact HTML5 will have for app developers is local data storage. Toptal’s Demir Selmanovic points out in The 5 Most Common HTML5 Mistakes that Web Storage’s local data stores are not encrypted, which introduces a potential security risk.
On the plus side, Web Storage data never travels to web servers, so it is more secure than old-style cookies and Flash LBOs. However, HTML5’s localStorage and sessionStorage values are easy for bad guys to modify, so you should avoid storing security tokens locally.
Web Storage’s window.localStorage and code.sessionStorage objects have identical APIs and are used to retain persistent data and session-only data, respectively. Name/value pairs are used to store domain-specific strings, and up to 5MB of data can be stored locally, none of which ever travels to the server.
Web Storage supports only string values, and it’s unstructured, so it doesn’t allow transactions, indexing, or searching. Conversely, IndexedDB’s data store is structured, transactional, and more like NoSQL in terms of performance. Its synchronous and asynchronous API makes possible more robust client-side data storage and access, although the API’s size and complexity make creating an IndexedDB polyfill a challenge.
File API enhancements facilitate local file access
When users interact with files in their browsers, the many back-and-forth trips between the client and server can be frustrating — to users and developers alike. HTML5’s File API lets users access and alter files in the browser with much less interaction with the server.
After accessing the FileList object, you render the file in the browser by loading one of the file objects into FileReader to generate a local URL that serves as the src in an image element.
The simplest way to manage your databases in a browser is by using the new Morpheus Virtual Appliance, which provides a single dashboard for provisioning, deploying, and monitoring your heterogeneous MySQL, MongoDB, Redis, and ElasticSearch databases. Morpheus offers a simple point-and-click interface for analyzing SQL, NoSQL, and in-memory databases across hybrid clouds in just minutes. Each database instance you create includes a free full replica set for built-in fault tolerance and fail over.
With the Morpheus database-as-a-service (DBaaS), you can migrate existing databases from a private cloud to the public cloud, or from public to private. A new instance of the same database type is created in the other cloud, and real-time replication keeps the two databases in sync. Visit the Morpheus site for pricing information and to create a free account.