开发者

What are the benefits of using sessionStorage? [duplicate]

This question already has answers here: When should I use html5 sessionStorage? (3 answers) Closed 1 year ago.

Just wondering what are the actual benefits of using HTML5's sessionStorage when storing HTML content to be used in a Javascript carousel?

Is it performance related? Load Times? 开发者_如何学运维Bandwidth?


Yes you'll use less bandwidth, it'll be better for performance because you can store information in your browser up to 5Mb. It's much more than with cookie.

For instance to set an item in the storage you can do:

sessionStorage.setItem("name1", "value1");

and to get the item

sessionStorage.getItem("name1");

The sessionStorage is relative to each subdomain/domain.


Yes. sessionStorage stores much more information than cookies can, and it is easier to access as well.

By storing data you need to access again locally, you avoid (or minimize) ajax calls, and in turn server and database loads.

This will result in faster page loads (as you will not need to wait for the server to provide the data), and bandwidth (as you have minimized communication with the server).


Theoretically (and probably actually in most cases), faster load time, as it is almost like the images are already cached (loading from the user rather than the server). I don't know much about it, but had looked into whether it would help as a storage for images on https connections. It did not help there (and in fact, may have made it worse).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜