替代Cookie在客户端存储数据。
Cookie存储数据缺点:
- Size: Cookies are limited to about 4 kilobytes in size.
- Bandwidth: Cookies are sent along with every HTTP transaction.
- Complexity: Cookies are difficult to manipulate correctly.
PersistJS优点:
- Small (9.3k minified, 3k gzipped)
- Standalone: Does not need any additional browser plugins or JavaScript libraries to work on the vast majority of current browsers.
- Consistent: Provides a consistent, opaque API, regardless of the browser.
- Extensible: Custom backends can be added easily.
- Backwards Compatible: Can fall back to flash or cookies if no client-side storage solution for the given browser is available.
- Forwards Compatible: Supports the upcoming versions of Internet Explorer, Firefox, and Safari (Opera too, if you have Flash).
- Unobtrusive: Capability testing rather than browser detection, so newer standards-compliant browsers will automatically be supported
与PersistJS类似功能项目包括:Dojo Storage。遗憾的是DojoStorage依赖Flash,没有安装Flash的浏览器DOJO storage不起作用。
原文地址http://www.zgkw.cn/forums/forums/74105/ShowThread.aspx#74105