AEM Dispatcherでキャッシュするリクエストはどれですか?

この記事では、AEM DispatcherがキャッシュしないHTTP リクエスト/レスポンスの理由と理由を説明します。

説明 description

環境

AEM Dispatcher 4.3.3

問題

このドキュメントでは、AEM Dispatcher モジュールを経由するリクエストとレスポンスのキャッシュ能力に影響を与える最も重要なシナリオについて説明します。 すべてのキャッシュルールはカバーされていません。

解決策 resolution

HTTP リクエストとキャッシュ ルール

DispatcherでHTTP リクエストをキャッシュするには、次のルールに従う必要があります。

  1. URLは絶対です(で動作しません)。 または…)にはファイル拡張子があり、URLのファイル名はファイルシステム上のファイルとして機能します。

    関連するログメッセージ :

    code language-none
    URI not canonical: %s.
    
    Unable to map URI to file: %s.
    
    cache file path too long
    
    temporary file path too long
    
    request URL has no extension
    

    :

    table 0-row-2 1-row-2
    /content/test not cached
    /content/test.html cached
  2. 最初のファイル拡張子の後にスラッシュはありません。

    関連するログメッセージ :

    code language-none
    request URL has trailing slash
    

    :

    table 0-row-2 1-row-2 2-row-2
    /content/test.html/ not cached
    /content/test.html/foo.jpg not cached
    /content/test.html cached
  3. HTTP GET メソッドまたはHEAD メソッドを使用します。

    関連するログメッセージ :

    code language-none
    request method is neither GET nor HEAD
    

    :

    table 0-row-2 1-row-2 2-row-2
    HEAD /content/test.html HTTP/1.1 cached
    GET /content/dam/test.jpg HTTP/1.1 not cached
    POST /content/test.html HTTP/1.1 not cached
  4. リクエストは、Dispatcherで定義された/CACHE => /RULESによって拒否されます。 任意のファーム設定。

    関連するログメッセージ :

    code language-none
    URI not  in cache rules: %s request URL not in cache rules
    

    :

    a. キャッシュなし

    code language-none
    Farm has /cache => /rules and a request is received for /content/test.html
    /cache
    {
      ...
      /rules
      {
        /0001 {
          type "deny"
          glob "*"
          }
      }
    }
    

    b. キャッシュ

    code language-none
    Farm has /cache => /rules and a request is received for /content/test.html
    /cache
    {
      ...
      /rules
      {
        /0001 {
          type "allow"
          glob "*"
          }
      }
    }
    
  5. HTTP リクエストに認証ヘッダーが含まれていないか、ヘッダーが含まれていますが、/ALLOWAUTHORIZEDはファーム設定で1に設定されています。

    関連するログメッセージ :

    code language-none
    request contains authorization
    

    :

    a. キャッシュなし

    code language-none
    HTTP Request:
    
    GET /content/test.html HTTP/1.1
    Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
    dispatcher.any farm /cache => /allowAuthorized configuration:
    /cache {
     /allowAuthorized “0”
    }
    

    b. キャッシュ

    code language-none
    HTTP Request:
    
    GET /content/test.html HTTP/1.1
    Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
    dispatcher.any farm /cache => /allowAuthorized configuration:
    /cache {
     /allowAuthorized “1”
    }
    
  6. HTTP リクエストには、cookie ヘッダーにログイントークンまたは認証Cookieが含まれているか、これらのCookieのいずれか(または両方)が含まれており、/ALLOWAUTHORIZEDはファーム設定で1に設定されています。

    関連するログメッセージ :

    code language-none
    request contains authorization
    

    :

    a. キャッシュなし

    code language-none
    HTTP Request:
    
    GET /content/test.html HTTP/1.1
    Cookie: login-token=...
    dispatcher.any farm /cache = /allowAuthorized configuration:
    /cache {
     /allowAuthorized “0”
    }
    
    code language-none
    HTTP Request:
    
    GET /content/test.html HTTP/1.1
    Cookie: authorization= YWxhZGRpbjpvcGVuc2VzYW1l
    dispatcher.any farm /cache = /allowAuthorized configuration:
    /cache {
     /allowAuthorized “0”
    }
    

    b. キャッシュ

    code language-none
    HTTP Request:
    
    GET /content/test.html HTTP/1.1
    Cookie: login-token=...
    dispatcher.any farm /cache => /allowAuthorized configuration:
    /cache {
     /allowAuthorized “1”
    }
    
  7. URLにQUERYSTRING パラメーターがあり、パラメーターはFARMの/IGNOREURLPARAMS CONFIGURATIONを介して無視できます。

    関連するログメッセージ :

    code language-none
    request contains a query string
    

    :

    a. キャッシュ

    code language-none
    HTTP Request:
    
    GET /content/test.html?test=1 HTTP/1.1
    Farm /cache configuration:
    
    /ignoreUrlParams {
        /0001 { /type “allow” /glob “*” }
    }
    
    code language-none
    HTTP Request:
    
    GET /content/test.html?test=1 HTTP/1.1
    Farm /cache configuration:
    /ignoreUrlParams {
        /0001 { /type “deny” /glob “*” }
        /0001 { /type “allow” /glob “test” }
    }
    

    b. キャッシュなし

    code language-none
    HTTP Request:
    
    GET /content/test.html?test=1 HTTP/1.1
    dispatcher.any farm /cache = /allowAuthorized configuration:
    /ignoreUrlParams {
        /0001 { /type “deny” /glob “*” }
        /0001 { /type “allow” /glob “q” }
    }
    

HTTP応答とキャッシュ ルール:

次の条件を満たす場合、AEMから返されるHTTP レスポンスはキャッシュ可能です。

  1. Dispatcherは、定義された「RENDERS」のいずれかから200 OK応答を送受信できます。

    注意: /rendersで/timeoutが設定されていない場合、または0に設定されている場合、インスタンスがダウンしていても、AEM インスタンスへの接続を永遠に待つことになります。

    関連するログメッセージ :

    code language-none
    Unable to send request to remote server. Unable to receive response from remote server. Remote server returned: %s No backend available.
    

    :

    table 0-row-2 1-row-2
    HTTP リクエスト:

    200 OK
    キャッシュ
    HTTP リクエスト:

    404 ページが見つかりません
    キャッシュなし
  2. 次の応答ヘッダーはいずれも応答に存在しません。

    • Dispatcher: no-cache
    • Cache-control: no-cache
    • Pragma: no-cache

    関連するログメッセージ :

    code language-none
    Backend forbids caching: %s, sent: %s" response contains no_cache
    

    :

    table 0-row-2 1-row-2 2-row-2 3-row-2
    HTTP Response:

    200 OK

    Dispatcher: no-cache
    キャッシュなし
    HTTP応答:

    200 OK

    キャッシュ制御:キャッシュなし
    キャッシュなし
    HTTP応答:

    200 OK

    Pragma: no-cache
    キャッシュなし
    HTTP応答:

    200 OK
    キャッシュ
  3. Content-lengthの値が0 バイトを超えています。 関連するログメッセージ :

    code language-none
    response content length is zero
    

    :

    table 0-row-2 1-row-2
    HTTP応答:

    200 OK

    コンテンツ長:0
    キャッシュなし
    HTTP応答:

    200 OK

    コンテンツ長:3120
    キャッシュ
recommendation-more-help
experience-cloud-kcs-help-kbarticles