2008-05-13 (火)
■ Apache2 互換な ETag の計算方法
sie.php でキャッシュを制御するのに使いたいので、調べてみたところ、 2通りのサンプルコードが見つかった。
ということで、drry+@-> PHP で Apache 風 ETag の生成を次のように変えると Apache と全く同じ ETag を生成できる。
修正した ETag 生成コード $etag = sprintf( '"%x-%x-%x"', $stats['ino'], $stats['size'], $stats['mtime'] * 1000000 );これからすると、Apache の内部では更新時刻をマイクロタイム単位で扱っているようだ。
Sample function that generates apache 2.2 ETag. Useful for scripts serving images or other cachable data.
$file="example.png"; // Inode $ETag = dechex(fileinode($file)); // Size $ETag.= "-".dechex(filesize($file)); // Modification time in useconds & (2^33-1) $ETag.= "-".dechex(((filemtime($file).str_repeat("0",6)+0) & (8589934591))); header("ETag: \"$ETag\");
念のため確認してみたが、確かにどちらのコードも Apache 2 と同じ ETag を出力する。 でも、前者の方がずっと分かりやすい。こちらのコードを使わせてもらおう。
[コメントを書く]
本日のリンク元
- 2 google検索(apache etag)
- 2 google検索(apache 計算)
- 2 google検索(ETag)
- 1 google検索(etag)
- 1 google検索(ETag 生成方法)
- 1 google検索(ETag)
- 1 google検索(ETag)
- 1 google検索("xps" apache)
- 1 google検索(php etag)
- 1 google検索(PHP ETAG)
- 1 google検索(apache etag php)
- 1 google検索(php etag)
- 1 google検索(php "Etag")
- 1 google検索(jquery + 計算)
- 1 google検索(etag)
- 1 google検索(etag)
- 1 google検索(apache etag )
- 1 google検索(apache etag 生成方法)
- 1 google検索(apache etag)
- 1 google検索(apache etag)
- 1 google検索(apache etag)
- 1 google検索(apache etag)
- 1 google検索(apache ETag)
- 1 google検索(PHP e-tag)
- 1 google検索(PHP 計算式)
- 1 google検索(Etag apache 2.2)
- 1 google検索(ETag php)
- 1 google検索(ETag IE)
- 1 google検索(ETag 生成 方法)
- 1 google検索(Apache Etag)
- 1 google検索(apache etag)
- 1 google検索(apache php メモリリーク)
- 1 google検索(ETag)
- 1 google検索(ETag 生成)
- 1 google検索(html etag)
- 1 google検索(php apache centos)
- 1 google検索(php apache メモリリーク)
- 1 google検索(php マイクロタイム)
- 1 google検索(etag 生成)
- 1 google検索(etag)
- 1 google検索(etag 生成方法)
- 1 google検索(apache etag)
- 1 google検索(apache 設定 etag)
- 1 google検索(ETag apache)
- 1 google検索(CentOS 5.2 Apach )
- 1 google検索(Apache Etag 計算)
- 1 google検索(角丸 計算式)
- 1 google検索(ETag 生成)
- 1 google検索(etag)
- 1 google検索(etag)
- 1 google検索(vmware centos apache)
- 1 google検索(PHP 計算)
- 1 google検索(apache メモリリーク)
- 1 google検索(apache etag)
- 1 google検索(apache etag)
- 1 google検索(ETag inode)
- 1 google検索(ETag)
- 1 google検索(ETag)
- 1 google検索(etag)
- 1 google検索(Apache Etag)
- 1 google検索(Etag)
- 1 http://www.google.co.jp/hws/search?hl=ja&q=etag ph...
- 1 http://www.google.co.jp/hws/search?hl=ja&q=ETag Ap...
- 1 http://www.google.co.jp/hws/search?hl=ja&q=ETag 生...
- 1 goo検索(Apache eTag)
- 1 http://feed.hotphpper.net/index.php?hours=168
- 1 http://del.icio.us/kj33
- 1 http://72.14.235.104/search?q=cache:O2Tjqck5w7AJ:w...
- 1 http://209.85.175.104/search?q=cache:BKaolwjkxaYJ:...
- 1 http://209.85.175.104/search?q=cache:BKaolwjkxaYJ:...
- 1 http://209.85.175.104/search?q=cache:BKaolwjkxaYJ:...
- 1 http://209.85.175.104/search?q=cache:BKaolwjkxaYJ:...
