Client | vue add session
BaseExampleClient-sidestorageisanexcellentwaytoquicklyaddperformancegainstoanapplication.Bystoringdataonthebrowseritself,youcanskipfetchinginformationfromtheservereverytimetheuserneedsit.Whileespeciallyusefulwhenoffline,evenonlineuserswillbenefitfromusingdatalocallyversusaremoteserver.Client-sidestoragecanbedonewithcookies[1],LocalStorage[2](technically“WebStorage”),IndexedDB[3],andWebSQL[4](adeprecatedmethodthatshouldnotbeusedinnewprojects).Inthiscookbookentrywe’llfocusonLocalStorage,thesim...
Base ExampleClient-side storage is an excellent way to quickly add performance gains to an application. By storing data on the browser itself, you can skip fetching information from the server every time the user needs it. While especially useful when offline, even online users will benefit from using data locally versus a remote server. Client-side storage can be done with cookies[1], Local Storage[2] (technically “Web Storage”), IndexedDB[3], and WebSQL[4] (a deprecated method that should not be used in new projects).
In this cookbook entry we’ll focus on Local Storage, the simplest of the storage mechanisms. Local Storage uses a key/value system for storing data. It is limited to storing only simple values but complex data can be stored if you are willing to encode and decode the values with JSON. In general, Local Storage is appropriate for smaller sets of data you would want to persist, things like user preferences or form data. Larger data with more c...