Quali richieste memorizza in cache il Dispatcher AEM?

Questo articolo determina il motivo e quali richieste/risposte HTTP non vengono memorizzate nella cache dal Dispatcher 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

Richieste HTTP e regole di caching

Affinché una richiesta HTTP possa essere memorizzata nella cache dal dispatcher, deve rispettare le seguenti regole:

  1. 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 extension
    

    Esempi:

    table 0-row-2 1-row-2
    /content/test not cached
    /content/test.html cached
  2. Non ci sono barre dopo la prima estensione del file.

    Messaggi di registro correlati:

    code language-none
    request URL has trailing slash
    

    Esempi:

    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. Utilizza il metodo HTTP GET o HEAD.

    Messaggi di registro correlati:

    code language-none
    request method is neither GET nor HEAD
    

    Esempi:

    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. La richiesta è negata da /CACHE => /RULES definite nel dispatcher. QUALSIASI CONFIGURAZIONE FARM.

    Messaggi di registro correlati:

    code language-none
    URI not  in cache rules: %s request URL not in cache rules
    

    Esempi:

    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 "*"
          }
      }
    }
    
  5. 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 authorization
    

    Esempi:

    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”
    }
    
  6. 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 authorization
    

    Esempi:

    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”
    }
    
  7. 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 string
    

    Esempi:

    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 risposta HTTP e caching:

La risposta HTTP restituita dall’AEM è memorizzabile in cache se sono soddisfatti i seguenti criteri:

  1. Il dispatcher è in grado di inviare e ricevere una risposta 200 OK da uno dei "RENDERS" definiti.

    Nota: In caso negativo /timeout è impostato su /renders o è impostato su 0, attenderebbe per sempre una connessione all’istanza AEM anche se l’istanza non è attiva.

    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 OK
    memorizzato nella cache
    Richiesta HTTP:

    Pagina 404 non trovata
    non memorizzato in cache
  2. Nessuna di queste intestazioni di risposta è presente nella risposta:

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

    Messaggi di registro correlati:

    code language-none
    Backend forbids caching: %s, sent: %s" response contains no_cache
    

    Esempi:

    table 0-row-2 1-row-2 2-row-2 3-row-2
    Risposta HTTP:

    200 OK

    Dispatcher: no-cache
    non memorizzato in cache
    Risposta HTTP:

    200 OK

    Cache-control: no-cache
    non memorizzato in cache
    Risposta HTTP:

    200 OK

    Pragma: no-cache
    non memorizzato in cache
    Risposta HTTP:

    200 OK
    memorizzato nella cache
  3. Il valore della lunghezza del contenuto è maggiore di ZERO BYTE.
    Messaggi di registro correlati:

    code language-none
    response content length is zero
    

    Esempi:

    table 0-row-2 1-row-2
    Risposta HTTP:

    200 OK

    Lunghezza contenuto: 0
    non memorizzato in cache
    Risposta HTTP:

    200 OK

    Lunghezza contenuto: 3120
    memorizzato nella cache
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f