AEM Dispatcher快取哪些請求?
本文會判斷AEM Dispatcher未快取為何以及哪些HTTP要求/回應。
說明 description
環境
AEM Dispatcher 4.3.3
問題
本檔案涵蓋最重要的案例,影響透過AEM Dispatcher模組之請求和回應的快取能力。 不包含所有快取規則。
解決方法 resolution
HTTP要求與快取規則
為了讓Dispatcher能夠快取HTTP請求,該請求必須遵循以下規則:
-
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
-
第一個副檔名後面沒有斜線。
相關記錄檔訊息:
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
-
它會使用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
-
在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 "*" } } }
-
HTTP請求不包含授權標頭,或包含標頭,但/ALLOWAUTHORIZED在FARM CONFIGURATION中設定為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” }
-
HTTP請求在Cookie標頭中包含登入權杖或授權Cookie,或包含這些Cookie其中一個(或兩者),且/ALLOWAUTHORIZED在FARM CONFIGURATION中設為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” }
-
URL中有一個QUERYSTRING引數,並且允許透過陣列的/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回應:
-
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 OKcached HTTP要求:
404找不到頁面未快取 -
回應中不會出現這些回應標頭:
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
Pragma: no-cache未快取 HTTP回應:
200 OKcached -
Content-length值大於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
Content-Length:3120cached