我可以在浏览器中缓存列表项吗?
问题描述:
我对多个SP列表进行了REST调用,并使用客户端代码将项目取回.我可以在浏览器中缓存这些项目一天吗?这样我就避免了调用REST调用,这既复杂又费时?谢谢
I did a REST call to multiple SP lists and got the items back using client code. Can I cache these items in the browser for a day? So that I avoid invoking REST call which is complex and time consuming? Thanks
答
绝对可以使用本地存储将其缓存在浏览器中,并可以在代码中对其进行控制.请尝试使用此代码段.
Absolutely you can cache it on your browser using local storage and can control them in your code.try this snippet.
.getJSON('http://restapiendpoint',函数(数据){ localStorage.setItem('key',JSON.stringify(data));
.getJSON('http://restapiendpoint', function (data) { localStorage.setItem('key', JSON.stringify(data));