Environment

AEM Dispatcher 4.2.3

Question

Which HTTP requests and responses do AEM Dispatcher cache?

Answer

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.

HTTP Request & Caching Rules:

For an HTTP request to be cacheable by the dispatcher, it must adhere to the following rules.

1. URL is absolute (not starting with . or ..), has a file extension and the filename in the url works as a file on the file system.

Related log messages:

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

Examples:

/content/test not cached
/content/test.html cached

2. It has no slashes after the first file extension.

Related log messages:

request URL has trailing slash

Examples:

/content/test.html/ not cached
/content/test.html/foo.jpg not cached
/content/test.html cached

3. It uses HTTP GET or HEAD method.

Related log messages:

request method is neither GET nor HEAD

Examples:

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. The request is denied by /cache => /rules defined in the dispatcher .any farm configuration.

Related log messages:

URI not in cache rules: %s
request URL not in cache rules

Examples:

Farm has /cache => /rules and a request is received for /content/test.html

/cache

{

  ...

  /rules

  {

    /0001 {

      type "deny"

      glob "*"

  }

}

not cached

Farm has /cache => /rules and a request is received for /content/test.html

/cache

{

  ...

  /rules

  {

    /0001 {

      type "allow"

      glob "*"

  }

}

cached

5. 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:

request contains authorization

Examples:

HTTP Request:

GET /content/test.html HTTP/1.1
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l

dispatcher.any farm /cache => /allowAuthorized configuration:

/cache {
  /allowAuthorized "0"
}

not cached

HTTP Request:

GET /content/test.html HTTP/1.1
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l

dispatcher.any farm /cache => /allowAuthorized configuration:

/cache {
  /allowAuthorized "1"
}

cached

6. 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:

request contains authorization

Examples:

Related log message:

Examples:

HTTP Request:

GET /content/test.html HTTP/1.1
Cookie: login-token=...

dispatcher.any farm /cache => /allowAuthorized configuration:

/cache {
  /allowAuthorized "0"
}

not cached

HTTP Request:

GET /content/test.html HTTP/1.1
Cookie: authorization=YWxhZGRpbjpvcGVuc2VzYW1l

dispatcher.any farm /cache => /allowAuthorized configuration:

/cache {
  /allowAuthorized "0"
}

not cached

HTTP Request:

GET /content/test.html HTTP/1.1
Cookie: login-token=...

dispatcher.any farm /cache => /allowAuthorized configuration:

/cache {
  /allowAuthorized "1"
}

cached

7. 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:

request contains a query string

Examples:

HTTP Request:

GET /content/test.html?test=1 HTTP/1.1

Farm /cache configuration:

/ignoreUrlParams {
   /0001 { /type "allow" /glob "*" } 
}

cached

HTTP Request:

GET /content/test.html?test=1 HTTP/1.1

Farm /cache configuration:

/ignoreUrlParams {
   /0001 { /type "deny" /glob "*" } 
   /0001 { /type "allow" /glob "test" }
}

cached

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" }
}

not cached

HTTP Response & Caching Rules:

The HTTP response returned from AEM is cacheable if the following criteria is met.

1. The dispatcher is able to send and receive a 200 OK response from the one of the defined "renders".

注意:

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:

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

Examples:

HTTP Request:

200 OK

cached

HTTP Request:

404 Page Not Found

not cached

2. None of these response headers are present in the response:

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

Related log message:

Backend forbids caching: %s, sent: %s"
response contains no_cache

Examples:

HTTP Response:

200 OK
Dispatcher: no-cache

not cached

HTTP Response:

200 OK
Cache-control: no-cache

not cached

HTTP Response:

200 OK
Pragma: no-cache

not cached

HTTP Response:

200 OK

cached

3. Content-Length value is greater than zero bytes.

Related log message:

response content length is zero

Examples:

HTTP Response:

200 OK
Content-Length: 0

not cached

HTTP Response:

200 OK
Content-Length: 3120

cached

本产品经 Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License 许可  Twitter™ 与 Facebook 中的内容不在 Creative Commons 的条款约束之下。

法律声明   |   在线隐私策略