浏览器存储
localStorage
- 存放数据没有存在过期时间,并仅通过JavaScript清除,或清除浏览器缓存/本地存储的数据
sessionStorage
- 存储会话信息,数据会在关闭浏览器或者标签的时候清空
- 数据不会被传输到服务端 Data is never transferred to the server.
- Storage limit is larger than a cookie (at least 5MB).
cookie
- Stores data that has to be sent back to the server with subsequent requests. Its expiration varies based on the type and the expiration duration can be set from either server-side or client-side (normally from server-side).
- Cookies are primarily for server-side reading (can also be read on client-side), localStorage and sessionStorage can only be read on client-side.
- Size must be less than 4KB.
- Cookies can be made secure by setting the httpOnly flag as true for that cookie. This prevents client-side access to that cookie
indexDB
- 键值对储存
- 异步 和LocalStorage不同,LocalStorage是同步的,异步设计是为了防止大量数据的读写。
- 支持事务
- 同源限制
- 储存空间大
- 支持二进制储存
indexDB的使用
评论
评论插件加载失败
正在加载评论插件