1. キャッシュ

キャッシュ

クライアントは、必要に応じて応答をキャッシュできます。 すべての応答には、ETag ヘッダーが存在します。

同じリソースに対する次回の要求では、クライアントはこのヘッダーの値を If-None-Match ヘッダーで送信できます。 これによりサーバーは、要求に対する応答が前回の要求とまったく同じであると判断し、304 Not Modified で応答します。 クライアントは、このようにしてキャッシュされた応答を再利用するように指示されるため、帯域幅を大幅に節約できます。

要求の例:

GET http://hostname/api
Host: hostname
Accept: application/json

応答の例:

HTTP/1.1 200 OK
Content-Length: content length
Content-Type: application/json; charset=utf-8
ETag: "hash string"

{
    "entitydefinitions":{
        "href":"http://hostname/api/entitydefinitions",
        "title":"The collection of entity definitions."
    },
    "entities":{
        "href":"http://hostname/api/entities",
        "title":"The collection of entities."
    },
    "entitydefinition_by_name":{
        "href":"http://hostname/api/entitydefinitions/{name}",
        "title":"Get the entity definition with the spe...",
        "is_template":true
    },
    "entity_by_id":{
        "href":"http://hostname/api/entities/{id}",
        "title":"Get the entity with the specified id.",
        "is_template":true
    }
}

フォローアップ要求の例:

GET http://hostname/api
Host: hostname
Accept: application/json
If-None-Match: "KEWz1VCrPJHbdBYEKfq4C3316wXW3VkwII61gtt8PO4="

フォローアップ応答の例:

HTTP/1.1 304 Not Modified
Content-Length: content length
Content-Type: application/json; charset=utf-8
ETag: "KEWz1VCrPJHbdBYEKfq4C3316wXW3VkwII61gtt8PO4="
この記事を改善するための提案がある場合は、 お知らせください!