ページ

2009年5月26日火曜日

WebKit検証(32) - キャッシュの中身

このエントリーをブックマークに追加 このエントリーを含むはてなブックマーク

キャッシュがどこかに作成されていないかと思い、探してみたところ ~/Library/Caches/ 配下に見つかった。


Cache.db というファイルが作成されていた。多分 SQLiteのDBと思い、sqlite3コマンドで読み込んでみたところその通りだった。

ターミナル

$ sqlite3 Cache.db 
SQLite version 3.4.0
Enter ".help" for instructions
sqlite> .tables
cfurl_cache_blob_data cfurl_cache_schema_version
cfurl_cache_response
sqlite>


3つのテーブルが作成されていた。定義や中のデータはこんな感じ。

cfulr_cache_schmea_version
(定義)

sqlite> .schema cfurl_cache_schema_version
CREATE TABLE cfurl_cache_schema_version(schema_version INTEGER);


(中身)
sqlite> select * from cfurl_cache_schema_version;
8



cfurl_cache_response
(定義)

sqlite> .schema cfurl_cache_response
CREATE TABLE cfurl_cache_response(
entry_ID INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE,
version INTEGER,
hash_value INTEGER,
storage_policy INTEGER,
request_key TEXT UNIQUE,
time_stamp NOT NULL DEFAULT CURRENT_TIMESTAMP);
CREATE INDEX request_key_index ON cfurl_cache_response(request_key);
CREATE INDEX time_stamp_index ON cfurl_cache_response(time_stamp);


(中身)
sqlite> select * from cfurl_cache_response;
1|0|462566830|0|http://www.apple.com/|2009-05-26 21:43:57
2|0|-632403425|0|http://images.apple.com/global/scripts/lib/prototype.js|2009-05-26 21:43:57
3|0|-1064591170|0|http://images.apple.com/global/scripts/lib/scriptaculous.js|2009-05-26 21:43:57
:
:



cfurl_cache_blob_data
(定義)

sqlite> .schema cfurl_cache_blob_data
CREATE TABLE cfurl_cache_blob_data(
entry_ID INTEGER PRIMARY KEY,
response_object BLOB,
request_object BLOB,
receiver_data BLOB,
proto_props BLOB,
user_info BLOB);
CREATE INDEX proto_props_index ON cfurl_cache_blob_data(entry_ID);


(中身)
sqlite> select * from cfurl_cache_blob_data where entry_ID=1;
entry_ID|response_object|request_object|receiver_data|proto_props|user_info
7|<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Array</key>
<array>
<dict>
<key>_CFURLString</key>
:
:
|<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en-us">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" l gen true for "http://www.apple.com" r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.apple.com" r



cfurl_cache_response にキャッシュ対象の URLとタイムスタンプなどのメタ情報が保存され、cfurl_cache_blob_data に実際のデータ(HTMLや画像)が格納されているようだ。

Cache.db はアプリを終了しても消えずに残っていた。

*検証環境
usesPageCache=1
webCacheModel=0