Possible to cache JSON to increase performance / load time?

后端 未结 6 1164
我寻月下人不归
我寻月下人不归 2020-12-13 11:14

I\'m using a JSON file to autopopulate a drop down list. It\'s by no means massive (3000 lines and growing) but the time taken to refresh the page is becoming very noticeab

6条回答
  •  醉话见心
    2020-12-13 12:01

    Once you've got your JSON data decoded into an object you can just keep the object around, it should persist until a page reload at least.

    If you want to persist between reloads you might want to look at HTML5's localStorage etc.

    You would need to come up with an age strategy, maybe just dump the current date in there with it as well so you can compare that and expire as needed.

提交回复
热议问题