AEM Dispatcher はどの要求をキャッシュしますか?

この記事では、AEM Dispatcher がキャッシュしない理由と HTTP 要求/応答を決定します。

説明 description

環境

AEM Dispatcher 4.3.3

問題

ドキュメントでは、AEM Dispatcher モジュールを介した要求と応答のキャッシュ機能に影響を与える最も重要なシナリオについて説明します。 すべてのキャッシュルールは適用されません。

解決策 resolution

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

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

  1. URL が絶対 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. HTTPGETまたは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. この要求は/CACHE =によって拒否されました> /RULES (Dispatcher で定義) 任意のファーム設定。

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

    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 リクエストに認証ヘッダーが含まれていないか、ヘッダーが含まれていますが、FARM CONFIGURATION で/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 ヘッダーに login-token または authorization Cookie が含まれているか、FARM CONFIGURATION でこれらの 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 設定で無視できるパラメーターです。

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

    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」の 1 つから 200 OK 応答を送受信できます。

    注意: いいえの場合 /timeout が/renders に設定されているか、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
    cached
    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 応答:

    200 OK

    Dispatcher: no-cache
    キャッシュされません
    HTTP 応答:

    200 OK

    Cache-control: no-cache
    キャッシュされません
    HTTP 応答:

    200 OK

    プラグマ:no-cache
    キャッシュされません
    HTTP 応答:

    200 OK
    cached
  3. コンテンツの長さの値が 0 バイトを超えています。
    関連するログメッセージ:

    code language-none
    response content length is zero
    

    :

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

    200 OK

    Content-Length: 0
    キャッシュされません
    HTTP 応答:

    200 OK

    コンテンツの長さ: 3120
    cached
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f