Hello
I need to work with the cache of all browsers, I need to save data in the cache and then do the reading using Jquery. Does anyone know of a site with a tutorial on the subject?
Thank you
Hello
I need to work with the cache of all browsers, I need to save data in the cache and then do the reading using Jquery. Does anyone know of a site with a tutorial on the subject?
Thank you
Using localStorage
localStorage saves data to the visitor's computer, which is linked to (and only accessible by) your domain. And to use it is very simple:
// Cria um item "usuario" com valor "Usuário 1"
window.localStorage.setItem('usuario', 'Usuário 1');
// Depois, em outra página ou aba, recupera esse item
var usuario = window.localStorage.getItem('usuario');
// Remove o item
window.localStorage.removeItem('usuario');
Using sessionStorage
sessionStorage does exactly the same thing, only the data is saved only during the session (and is deleted when the visitor closes the browser / tab):
// Cria um item "usuario" com valor "Usuário 1"
window.sessionStorage.setItem('usuario', 'Usuário 1');
// Depois, em outra página ou aba, recupera esse item
var usuario = window.sessionStorage.getItem('usuario');
// Remove o item
window.sessionStorage.removeItem('usuario');