麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 編程 > JSP > 正文

介紹瀏覽器緩存數(shù)據(jù)的處理

2024-09-05 00:23:39
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

今天我們?cè)俅位仡櫼幌聻g覽器緩存數(shù)據(jù)方面的內(nèi)容:

1.針對(duì)IE6以上(含)內(nèi)核的瀏覽器,我們可以使用UserData 行為(userData Behavior)

說(shuō)明:

userData 行為通過(guò)將數(shù)據(jù)寫(xiě)入一個(gè)UserData存儲(chǔ)區(qū)(UserData store)來(lái)保存數(shù)據(jù),userData可以將數(shù)據(jù)以xml格式保存在客戶端計(jì)算機(jī)上,如果你用的是 Windows 2000 或者 Windows xp,是保存在C:/Documents and Settings/Liming/UserData/文件夾下(如果操作系統(tǒng)不是安裝在C盤(pán),那么C就應(yīng)該是操作系統(tǒng)所在的分區(qū))。該數(shù)據(jù)將一直存在,除非你人為刪除或者用腳本設(shè)置了該數(shù)據(jù)的失效期。userData行為提供了一個(gè)比Cookie更具有動(dòng)態(tài)性和更大容量的數(shù)據(jù)結(jié)構(gòu)。每頁(yè)的UserData 存儲(chǔ)區(qū)數(shù)據(jù)大小可以達(dá)到64 Kb,每個(gè)域名可以達(dá)到640 Kb。userData 行為通過(guò)sessions為每個(gè)對(duì)象分配UserData存儲(chǔ)區(qū)。使用save和load方法將UserData存儲(chǔ)區(qū)數(shù)據(jù)保存在緩存(cache)中。一旦UserData存儲(chǔ)區(qū)保存以后,即使IE瀏覽器關(guān)閉或者刷新了,下一次進(jìn)入該頁(yè)面,數(shù)據(jù)也能夠重新載入而不會(huì)丟失。出于安全的考慮,相同協(xié)議使用同一個(gè)文件夾保存UserData存儲(chǔ)區(qū)數(shù)據(jù)。

使用:

(1)首先必須在行內(nèi)或文檔的head部分聲明如下樣式:
Quote:

.userData {behavior:url(#default#userdata);}

或者使用如下js代碼來(lái)聲明:


Quote:

document.documentElement.addBehavior(”#default#userdata”);

(2)成員:


Quote:

expires 設(shè)置或取得使用userData行為保存數(shù)據(jù)的失效日期,使用方法:對(duì)象ID.expires = UTC格式的時(shí)間字符串;

getAttribute() 取得指定的屬性值;

load(存儲(chǔ)區(qū)名) 從userData存儲(chǔ)區(qū)載入存儲(chǔ)的對(duì)象數(shù)據(jù);

removeAttribute() 刪除指定的屬性值;

save(存儲(chǔ)區(qū)名) 將對(duì)象存儲(chǔ)到一個(gè)userData存儲(chǔ)區(qū);

setAttribute() 設(shè)置指定的屬性值;

XMLDocument 取得存儲(chǔ)該對(duì)象數(shù)據(jù)的XML DOM引用


(3)示例:


Quote:

document.documentElement.addBehavior("#default#userdata");

document.documentElement.load("t");

document.documentElement.setAttribute("value", "test");

document.documentElement.save("t");


2.針對(duì)Firefox2(含)以上內(nèi)核的瀏覽器,我們可以使用globalStorage

說(shuō)明:

This is a global object (globalStorage) that maintains multiple PRivate storage areas that can be used to hold data over a long period of time (e.g. over multiple pages and browser sessions).

Specifically, the globalStorage object provides access to a number of different storage objects into which data can be stored. For example, if we were to build a web page that used globalStorage on this domain (developer.mozilla.org) we’d have the following storage object available to us:

globalStorage[’developer.mozilla.org’] - All web pages within the developer.mozilla.org sub-domain can both read and write data to this storage object.

使用:

globalStorage[location.hostname]["t"] = “test”;//賦值

var ret = globalStorage[location.hostname]["t"];//取值

globalStorage.removeItem("t");//刪除

備注:

在firefox2 中,我們可以在tc-eb-test00.tc.baidu.com 上的頁(yè)面內(nèi)使用globalStorage[“baidu.com“][“t“]=“test“來(lái)賦值,但是到了firefox3這么做卻會(huì)得到一個(gè)錯(cuò)誤提示,原因是firefox3的安全策略要求在使用 globalStorage時(shí),指定的域名和實(shí)際的域名必須嚴(yán)格匹配!

3.Database Storage,HTML5里的內(nèi)容,目前僅有Safari支持

說(shuō)明:

This section is non-normative.

4.針對(duì)其它瀏覽器,如常見(jiàn)的Opera,我們可以使用Cookie

說(shuō)明:

A cookie is a small piece of information stored by the browser. Each cookie is stored in a name=value; pair called a crumb—that is, if the cookie name is “id” and you want to save the id’s value as “this”, the cookie would be saved as id=this. You can store up to 20 name=value pairs in a cookie, and the cookie is always returned as a string of all the cookies that apply to the page. This means that you must parse the string returned to find the values of individual cookies.

Cookies accumulate each time the property is set. If you try to set more than one cookie with a single call to the property, only the first cookie in the list will be retained.

You can use the Microsoft® JScript® split method to extract a value stored in a cookie.

備注:

現(xiàn)代瀏覽器一般默認(rèn)都支持cookie,但是使用cookie也有幾個(gè)致命的弱點(diǎn):存儲(chǔ)的信息量太少,頁(yè)面向服務(wù)器發(fā)送請(qǐng)求的同時(shí)cookie也會(huì)被發(fā)送,無(wú)形中浪費(fèi)用戶的帶寬。

5.其它解決方案

Google Gear:Google開(kāi)發(fā)出的一種本地存儲(chǔ)技術(shù);

Flash:利用Flash也可以實(shí)現(xiàn)本地存儲(chǔ)

這兩種方法的優(yōu)點(diǎn)是:能支持所有的OS和瀏覽器(Google Gear目前僅支持IE5+和Firefox1.5+);缺點(diǎn)是需要用戶安裝額外的插件,使用起來(lái)不如前面其它3種方法簡(jiǎn)便。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 91在线播放国产 | 久久国产精品一区 | 麻豆自拍偷拍视频 | 免费在线观看中文字幕 | 精品无码久久久久久国产 | 91短视频网址 | 亚洲综合视频在线播放 | 亚洲视频综合网 | 国产亚洲精品久久777777 | 中文字幕在线视频日本 | 98色视频| 国产一区二区三区四区五区在线 | 中文字幕一区久久 | 欧美一级毛片一级毛片 | 久久精品视频69 | 精品一区二区三区日本 | 精品一区二区三区在线播放 | 羞羞网站视频 | 91精品国产99久久久久久 | 国产精品成人久久久久a级 欧美特黄一级高清免费的香蕉 | 午夜精品久久久久久久久久久久久蜜桃 | 国产成人精品区一区二区不卡 | 91精品国产91久久久久久吃药 | 国产一级性生活视频 | 国产一区二区三区在线观看视频 | 日韩一级电影在线观看 | 全黄性性激高免费视频 | 91福利影视 | 在线1区| 欧美成人一区二区三区 | 黄色av一区二区三区 | 免费a网| 精品久久久久99 | 国产一级一区 | 久久激情小视频 | 午夜视频观看 | 免费毛片视频 | 国产不卡av在线 | 精品一区二区免费视频视频 | 久久精品久久久久 | 婷婷久久青草热一区二区 |