Which requests does AEM Dispatcher cache?
This article determines why and which HTTP requests/responses are not being cached by the AEM Dispatcher.
Description description
Environment
AEM Dispatcher 4.3.3
Issue
The documentation covers the most important scenarios that affect the cache-ability of requests and responses which go through the AEM Dispatcher module. All cache rules are not covered.
Resolution resolution
HTTP Request & Caching Rules
For an HTTP request to be cacheable by the dispatcher, it must adhere to the following rules:
-
URL is absolute (not working with . or …), has a file extension, and the filename in the URL works as a file on the file system.
Related log messages:
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 extensionExamples:
table 0-row-2 1-row-2 /content/testnot cached/content/test.htmlcached -
It has no slashes after the first file extension.
Related log messages:
code language-none request URL has trailing slashExamples:
table 0-row-2 1-row-2 2-row-2 /content/test.html/not cached/content/test.html/foo.jpgnot cached/content/test.htmlcached -
It uses HTTP GET or HEAD method.
Related log messages:
code language-none request method is neither GET nor HEADExamples:
table 0-row-2 1-row-2 2-row-2 HEAD /content/test.html HTTP/1.1cachedGET /content/dam/test.jpg HTTP/1.1not cachedPOST /content/test.html HTTP/1.1not cached -
The request is denied by /CACHE =
>/RULES defined in the dispatcher. ANY FARM CONFIGURATION.Related log messages:
code language-none URI not in cache rules: %s request URL not in cache rulesExamples:
a. Not cached
code language-none Farm has /cache => /rules and a request is received for /content/test.html /cache { ... /rules { /0001 { type "deny" glob "*" } } }b. Cached
code language-none Farm has /cache => /rules and a request is received for /content/test.html /cache { ... /rules { /0001 { type "allow" glob "*" } } } -
The HTTP request does not contain an authorization header or it contains the header but /ALLOWAUTHORIZED is set to 1 in the FARM CONFIGURATION.
Related log messages:
code language-none request contains authorizationExamples:
a. Not cached
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. Cached
code language-none HTTP Request: GET /content/test.html HTTP/1.1 Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l dispatcher.any farm /cache => /allowAuthorized configuration: /cache { /allowAuthorized “1” } -
The HTTP request contains login-token or authorization cookie in the cookie header, or it contains either (or both) of those cookies and /ALLOWAUTHORIZED is set to 1 in the FARM CONFIGURATION.
Related log messages:
code language-none request contains authorizationExamples:
a. Not cached
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. Cached
code language-none HTTP Request: GET /content/test.html HTTP/1.1 Cookie: login-token=... dispatcher.any farm /cache => /allowAuthorized configuration: /cache { /allowAuthorized “1” } -
There’s a QUERYSTRING parameter in the URL and the parameter is allowed to be ignored via the FARM’S /IGNOREURLPARAMS CONFIGURATION.
Related log messages:
code language-none request contains a query stringExamples:
a. Cached
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. Not cached
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 Response & Caching Rules:
The HTTP response returned from AEM is cacheable if the following criteria are met:
-
The dispatcher is able to send and receive a 200 OK response from one of the defined “RENDERS”.
Note: If no /timeout is set on the /renders or it is set to 0 then it would wait forever for a connection to the AEM instance even if the instance is down.
Related log messages:
code language-none Unable to send request to remote server. Unable to receive response from remote server. Remote server returned: %s No backend available.Examples:
table 0-row-2 1-row-2 HTTP Request:
200 OKcached HTTP Request:
404 Page Not Foundnot cached -
None of these response headers are present in the response:
Dispatcher: no-cacheCache-control: no-cachePragma: no-cache
Related log messages:
code language-none Backend forbids caching: %s, sent: %s" response contains no_cacheExamples:
table 0-row-2 1-row-2 2-row-2 3-row-2 HTTP Response:
200 OK
Dispatcher: no-cachenot cached HTTP Response:
200 OK
Cache-control: no-cachenot cached HTTP Response:
200 OK
Pragma: no-cachenot cached HTTP Response:
200 OKcached -
Content-length value is greater than ZERO BYTES.
Related log messages:code language-none response content length is zeroExamples:
table 0-row-2 1-row-2 HTTP Response:
200 OK
Content-Length: 0not cached HTTP Response:
200 OK
Content-Length: 3120cached