Implementing caching using local storage
At the moment, while viewing an Employees
page component, QuickGrid can sort the employees without making a call to the web service. But the Employees
component must call the web service every time we navigate between pages because the component’s data is stored in memory and its lifetime matches its page.
All modern browsers support two types of storage: local and session. Session storage is restricted to the current browser tab and current session. As soon as the tab closes, the storage is removed. Local storage is available across multiple tabs and sessions, but it is limited to the current domain, like example.com
, so, for example, google.com
cannot access it. Both are dictionaries that use string
values for both the key and value, so we will need to parse types stored in them.
Blazor cannot directly access browser resources like storage. We must create JavaScript code to interoperate between .NET and the browser. Rather...