2008-09-24

ETag って特に書式ないの?

RFC 2616 - Hypertext Transfer Protocol – HTTP/1.1

3.11 Entity Tags

Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the ETag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. The definition of how they are used and compared as cache validators is in section 13.3.3. An entity tag consists of an opaque quoted string, possibly prefixed by a weakness indicator.

weakness indicator と quote 以外はなんにも言ってない気がする。

実際例に挙がっている文字と例えば Apache の返す ETag 文字列とはまったく異なる。要は

リソースの変化が検出できる仕様になっていて " で囲まれていれば何を基準にどんな文字列を生成するのも自由

ってことかな?

あーなるほど。この解釈で合ってるみたい。

  • Apache はデフォルトでは inode, mtime, size を - で結んだ文字列を返す
    • core - Apache HTTP サーバ
    • inode が絡むとスケールアウトさせられないので大規模なサービスでは inode は使わない設定にするらしい。
  • Rails は response body の md5 を返す

単純なファイルを返す場合以外は Rails 方式を採用するのがいい感じだ。

About

例によって個人のなんちゃらです