SD Tidbits
Published in

SD Tidbits

Storage Possibilities


Young man peering into an open gift box
Photo by Ron Lach :

While there seems to be finite types of data you can store in a browser, we miss out on some performance benefits if we don’t leverage session or local storage.

Sure, tools like NgRx provide more optimized means of state management in an application. Moreover, you are less limited to what you can put in an NgRx store compared to a browser’s localStorage — depending on whether the use case is viable.

By finite types of data, I mostly mean non-secret:

  • data you need saved unless the browser is closed (give or take a time limit) — session storage
  • data you need saved even after the browser is closed — local storage
  • data you need saved and refreshed if there’s an update…unless the app session is ended — app state management

By optimized, I mostly mean forgoing those extra HTTP requests when the data hardly changes. This spells faster data retrievals, or less loading time to users.

Let’s think about my overused example of the library application that retrieves book titles. Book Titles, ISBNs, and Authors hardly change. Readers and the contents of their Carts, however, do.

I could retrieve a list of available book titles when it’s first needed and use app state management to store the list. I’m assuming it’s a huge list and I’m not trying to turn my browser into another database.

I could store and update the contents of the reader’s cart in session storage or local storage. Nothing too dense, maybe just ISBNs and reader IDs. Which storage depends on the pros you want.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store