Skip to content

29.Web Storage 与 Cookie 相比存在的优势 #29

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
webVueBlog opened this issue Mar 12, 2020 · 2 comments
Open

29.Web Storage 与 Cookie 相比存在的优势 #29

webVueBlog opened this issue Mar 12, 2020 · 2 comments
Labels
浏览器 浏览器

Comments

@webVueBlog
Copy link
Member

No description provided.

@webVueBlog webVueBlog added the 浏览器 浏览器 label Mar 12, 2020
@webVueBlog
Copy link
Member Author

(1)、存储空间更大:IE8 下每个独立的存储空间为 10M,其他浏览器实现略
有不同,但都比 Cookie 要大很多。

(2)、存储内容不会发送到服务器:当设置了 Cookie 后,Cookie 的内容会随
着请求一并发送的服务器,这对于本地存储的数据是一种带宽浪费。而 Web
Storage 中的数据则仅仅是存在本地,不会与服务器发生任何交互。

(3)、更多丰富易用的接口:Web Storage 提供了一套更为丰富的接口,如
setItem,getItem,removeItem,clear 等,使得数据操作更为简便。cookie 需要自己封
装。

(4)、独立的存储空间:每个域(包括子域)有独立的存储空间,各个存储空
间是完全独立的,因此不会造成数据混乱。

@webVueBlog
Copy link
Member Author

(1) more storage space: under IE8, each independent storage space is 10M, which is slightly implemented by other browsers
There are differences, but both are much bigger than cookies.

(2) the stored contents will not be sent to the server: when the Cookie is set, the contents of the Cookie will follow
Sending requests to the server along with them is a waste of bandwidth for locally stored data. And the Web
The data in Storage is stored locally and does not interact with the server.

(3) more rich and easy-to-use interfaces: Web Storage provides a set of richer interfaces, such as
SetItem, the getItem, removeItem, clear, etc., make the data operation more simple. Cookies need to be sealed by themselves
Loading.

(4) independent storage space: each domain (including subdomains) has independent storage space, and each storage is empty
It is completely independent, so there is no data clutter.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
浏览器 浏览器
Projects
None yet
Development

No branches or pull requests

1 participant