Quali richieste vengono memorizzate nella cache del Dispatcher AEM?
Questo articolo determina il motivo e quali richieste/risposte HTTP non vengono memorizzate nella cache dal Dispatcher dell’AEM.
Descrizione description
Ambiente
AEM Dispatcher 4.3.3
Problema
La documentazione descrive gli scenari più importanti che influenzano la cache-ability delle richieste e delle risposte che passano attraverso il modulo Dispatcher dell’AEM. Tutte le regole della cache non sono coperte.
Risoluzione resolution
Regole di richiesta HTTP e caching
Affinché una richiesta HTTP possa essere memorizzata nella cache dal dispatcher, deve rispettare le seguenti regole:
-
L'URL è assoluto (non funziona con . o …), ha un'estensione di file e il nome del file nell'URL funziona come un file sul file system.
Messaggi di registro correlati:
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 extensionEsempi:
table 0-row-2 1-row-2 /content/testnot cached/content/test.htmlcached -
Non ci sono barre dopo la prima estensione del file.
Messaggi di registro correlati:
code language-none request URL has trailing slashEsempi:
table 0-row-2 1-row-2 2-row-2 /content/test.html/not cached/content/test.html/foo.jpgnot cached/content/test.htmlcached -
Utilizza il metodo HTTP GET o HEAD.
Messaggi di registro correlati:
code language-none request method is neither GET nor HEADEsempi:
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 -
La richiesta è negata da /CACHE =
>/RULES defined in the dispatcher. QUALSIASI CONFIGURAZIONE FARM.Messaggi di registro correlati:
code language-none URI not in cache rules: %s request URL not in cache rulesEsempi:
a. Non memorizzato in cache
code language-none Farm has /cache => /rules and a request is received for /content/test.html /cache { ... /rules { /0001 { type "deny" glob "*" } } }b. Memorizzazione in cache
code language-none Farm has /cache => /rules and a request is received for /content/test.html /cache { ... /rules { /0001 { type "allow" glob "*" } } } -
La richiesta HTTP non contiene un'intestazione di autorizzazione oppure contiene l'intestazione, ma /ALLOWAUTHORIZED è impostato su 1 nella CONFIGURAZIONE FARM.
Messaggi di registro correlati:
code language-none request contains authorizationEsempi:
a. Non memorizzato in cache
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. Memorizzazione in cache
code language-none HTTP Request: GET /content/test.html HTTP/1.1 Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l dispatcher.any farm /cache => /allowAuthorized configuration: /cache { /allowAuthorized “1” } -
La richiesta HTTP contiene il token di accesso o il cookie di autorizzazione nell’intestazione del cookie, oppure uno o entrambi i cookie e /ALLOWAUTHORIZED è impostato su 1 nella CONFIGURAZIONE FARM.
Messaggi di registro correlati:
code language-none request contains authorizationEsempi:
a. Non memorizzato in cache
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. Memorizzazione in cache
code language-none HTTP Request: GET /content/test.html HTTP/1.1 Cookie: login-token=... dispatcher.any farm /cache => /allowAuthorized configuration: /cache { /allowAuthorized “1” } -
Nell’URL è presente un parametro QUERYSTRING e il parametro può essere ignorato tramite la CONFIGURAZIONE /IGNOREURLPARAMS DELLA FARM.
Messaggi di registro correlati:
code language-none request contains a query stringEsempi:
a. memorizzato in cache
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. Non memorizzato in cache
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” } }
Regole di cache e risposta HTTP:
La risposta HTTP restituita dall’AEM è memorizzabile in cache se sono soddisfatti i seguenti criteri:
-
Il dispatcher è in grado di inviare e ricevere una risposta 200 OK da uno dei "RENDERS" definiti.
Nota: se non è impostato alcun /timeout in /renders o è impostato su 0, attenderebbe per sempre una connessione all'istanza AEM anche se l'istanza è inattiva.
Messaggi di registro correlati:
code language-none Unable to send request to remote server. Unable to receive response from remote server. Remote server returned: %s No backend available.Esempi:
table 0-row-2 1-row-2 Richiesta HTTP:
200 OKmemorizzato nella cache Richiesta HTTP:
Pagina 404 non trovatanon memorizzato in cache -
Nessuna di queste intestazioni di risposta è presente nella risposta:
Dispatcher: no-cacheCache-control: no-cachePragma: no-cache
Messaggi di registro correlati:
code language-none Backend forbids caching: %s, sent: %s" response contains no_cacheEsempi:
table 0-row-2 1-row-2 2-row-2 3-row-2 Risposta HTTP:
200 OK
Dispatcher: no-cachenon memorizzato in cache Risposta HTTP:
200 OK
Cache-control: no-cachenon memorizzato in cache Risposta HTTP:
200 OK
Pragma: no-cachenon memorizzato in cache Risposta HTTP:
200 OKmemorizzato nella cache -
Il valore della lunghezza del contenuto è maggiore di ZERO BYTE.
Messaggi di registro correlati:code language-none response content length is zeroEsempi:
table 0-row-2 1-row-2 Risposta HTTP:
200 OK
Lunghezza contenuto: 0non memorizzato in cache Risposta HTTP:
200 OK
Lunghezza contenuto: 3120memorizzato nella cache