客户端数据本地存储

发布于 2024-10-14 06:14:26 字数 134 浏览 7 评论 0原文

我想在客户端存储一些数据。 Cookie 是我的第一倾向,但它们会随每个请求一起发送,对吧?有没有一种方法可以在不传输数据的情况下存储数据?我不一定想为每个请求增加 10-20k 的开销。 HTML 5 网络存储是唯一的替代方案吗?有多少浏览器采用了它?

I want to store some data client side. Cookies are my first inclination, but they get sent with every request, right? Is there a way to store data without it being transferred? I don't necessarily want to add 10-20k of overhead for every request. Is the only alternative HTML 5 webstorage and how many browsers have adopted that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

冷情妓 2024-10-21 06:14:26

html5 存储已广泛部署,

HTML5 STORAGE SUPPORT
IE  FIREFOX SAFARI  CHROME  OPERA   IPHONE  ANDROID
8.0+    3.5+    4.0+    4.0+    10.5+   2.0+    2.0+

您可以了解更多信息 @ http://diveintohtml5.ep.io/storage.html< /a>

html5 storage is widely deployed

HTML5 STORAGE SUPPORT
IE  FIREFOX SAFARI  CHROME  OPERA   IPHONE  ANDROID
8.0+    3.5+    4.0+    4.0+    10.5+   2.0+    2.0+

you can find out more @ http://diveintohtml5.ep.io/storage.html

零崎曲识 2024-10-21 06:14:26

不,并非所有 cookie 都会随每个请求一起发送。您可以检查 cookie 是否存在,如果不存在则创建它,如果存在则读取它。对于少量数据来说,Cookie 仍然是一个很好的跨浏览器选项。

No, not all cookies get sent with every request. You can check to see if a cookie exists, if not create it, and if so, read it. Cookies are still a good cross-browser option for small amounts of data.

孤独难免 2024-10-21 06:14:26

http://fsojs.com 支持强大的文件存储客户端,但目前仅适用于 Chrome

http://fsojs.com supports robust file storage client-side, but only works with Chrome at the moment

甲如呢乙后呢 2024-10-21 06:14:26

正如您所提到的,Cookie 是一种选项,HTML5 规范中的 Web 存储也是一种选项。还可以使用 Flash 来存储数据,其额外好处是该数据可以在同一台计算机上的多个浏览器中保留,但缺点是您需要为没有 Flash 的用户提供后备方案。

就个人而言,将数据保存在服务器上(由会话 ID 或 cookie 标识)将是我的做法,您可以控制数据,并且不必担心当用户清除缓存或切换机器时丢失数据/设备。它也是最容错的,因为它不依赖于浏览器功能和/或插件(也许除了 cookie)。

另一件事,如果您正在寻找使用上述所有内容(cookie、闪存、网络存储)的客户端数据存储的抽象,请查看 Evercookie

As you have mentioned, cookies are an options and so is web storage in the HTML5 spec. There's also the ability to use Flash to store data with the added benefit that this data persists across multiple browsers on the same machine, but the drawback that you'll need a fallback for users who don't have Flash.

Personally, keeping the data on the server (identified by the session id or cookie) would be my way to do it, you have control of the data and don't have to worry about losing it when the user clears their cache or switches machines/devices. It's also the most fault-tolerant because it doesn't rely on browser features and/or plugins (other than perhaps cookies).

One more thing, if you're looking for an abstraction of client-side data storage that uses all of the above (cookies, flash, web storage) check out Evercookie

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文