Adel Benyahia
Feb 21, 2023

--

It Will be a good practice to add an expiration date to the stored response in the local storage, before storing the data as JSON.

const expireIn= 1000x60x60x24; // one day
const item = {
value: data,
expiry: now.getTime() + expireIn,
}
...
localStorage (url, item)

Thanks for sharing 👍

--

--

Adel Benyahia

Web application developer (HTML │ CSS │ JS | ReactJS | NextJS | NestJS | MERN)