博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
浏览器的本地存储方案及跨域
阅读量:6162 次
发布时间:2019-06-21

本文共 1641 字,大约阅读时间需要 5 分钟。

hot3.png

浏览器的本地存储方案

 

1 IndexedDB exmample

 is the successor to both LocalStorage and WebSQL, designed to replace them as the “one true” browser database. It exposes an asynchronous API that supposedly avoids blocking the DOM, but as we’ll see below, it doesn’t necessarily live up to the hype. Browser support is , with only Chrome and Firefox having fully usable implementations.

2 WebSQL

 is an API that is  (and Android and iOS by extension). It provides an asynchronous, transactional interface to . Since 2010, it has been deprecated in favor of IndexedDB.

3 LocalStorage(跨域时ios 10+下退出应用会自动清除,安卓不会)

 is a lightweight way to store key-value pairs. The API is very simple, but usage is  in many browsers. Plus the API is synchronous, so as we’ll see later, it can block the DOM. Browser support is .

为何LocalStorage会在iOS里被清除的原因:

WebKit data (localstorage or local SQLite) are now stored in Library/ Caches folder (instead of Library/WebKit folder). This is a big problem for all apps using UIWebView and storing user data, because they will no longer be backed up and may be deleted. There are a lot of apps using localstorage or SQLite as a critical feature.

The SQLite database gets deleted because the database is saved in a location on the filesystem which Apple does not consider to contain persistent data.

The WebKit data are stored in Library/Caches folder, and can be 

deleted
source from :  如果是自建app可以设置缓存文件的路径到Documents目录下,如果是第三方app没做这样的保护就没戏了。。

这里有一个跨域名(子域名使用的是iframe嵌入页面)写入localStorage的方案:

4 Cookie

不能跨域,包括曾经大量使用的p3p技巧。

5 the File API

6 window.name

7 SessionStorage

8 the Service Worker cache

转载于:https://my.oschina.net/swingcoder/blog/1586976

你可能感兴趣的文章
[转]如何重构代码--重构计划
查看>>
类中如何对list泛型做访问器??
查看>>
C++解析XML--使用CMarkup类解析XML
查看>>
P2P应用层组播
查看>>
Sharepoint学习笔记—修改SharePoint的Timeouts (Execution Timeout)
查看>>
CSS引入的方式有哪些? link和@import的区别?
查看>>
Redis 介绍2——常见基本类型
查看>>
asp.net开发mysql注意事项
查看>>
(转)Cortex-M3 (NXP LPC1788)之EEPROM存储器
查看>>
ubuntu set defult jdk
查看>>
[译]ECMAScript.next:TC39 2012年9月会议总结
查看>>
【Xcode】编辑与调试
查看>>
用tar和split将文件分包压缩
查看>>
[BTS] Could not find stored procedure 'mp_sap_check_tid'
查看>>
PLSQL DBMS_DDL.ALTER_COMPILE
查看>>
Activity生命周期
查看>>
高仿UC浏览器弹出菜单效果
查看>>
Ubuntu忘记密码,进不了系统的解决方法
查看>>
[原创]白盒测试技术思维导图
查看>>
<<Information Store and Management>> 读书笔记 之八
查看>>