Prerender: Request Forwarding (High Level) - NCIOCPL/cgov-digital-platform GitHub Wiki

General Case

  1. A bot requests an application page, (e.g. a definition for "carcinoma")
  2. An Akamai rule detects that the path is eligible for prerendering and forwards the request to the prerender service.
  3. The prerender service makes a new request for the page, appearing as a standard user.
  4. The application (e.g. the glossary application) returns the page.
  5. The prerender service executes the page logic and returns the generated HTML to Akamai.
  6. The bot receives the generated HTML in response to the original request.

sequenceDiagram

  participant GoogleBing
  participant Akamai1 as Akamai
  participant Prerender
  participant Akamai2 as Akamai
  participant Drupal

  GoogleBing-->>+Akamai1: Request as GoogleBing
  Akamai1-->>+Prerender: (forward)
  Prerender-->>+Akamai2:  Request as standard user
  Akamai2-->>+Drupal: (forward)
  Drupal-->>-Akamai2: Application page
  Akamai2-->>-Prerender: (return)
  Prerender-->Prerender: Execute Application
  Prerender-->>-Akamai1: Static HTML
  Akamai1-->>-GoogleBing: (return)

Error Handling

Page Not Found

  1. A bot requests an application page which does not exist (e.g. a definition for "Qwertium")
  2. An Akamai rule detects that the path is generally eligible for prerendering and forwards the request to the prerender service.
  3. The prerender service makes a new request for the page, appearing as a standard user.
  4. The application (e.g. the glossary application) determines the page should not exist and outputs the tag <meta name="prerender-status-code" content="404" data-react-helmet="true">.
  5. The prerender service detects the tag and returns a 404 status to Akamai.
  6. Akamai detects the 404 status and triggers the "Fancy 404" rule.
  7. The bot receives a 404 status in response to the original request.

sequenceDiagram

  participant GoogleBing
  participant Akamai1 as Akamai
  participant Prerender
  participant Akamai2 as Akamai
  participant Drupal

  GoogleBing-->>+Akamai1: Request as GoogleBing
  Akamai1-->>+Prerender: (forward)
  Prerender-->>+Akamai2:  Request as standard user
  Akamai2-->>+Drupal: (forward)
  Drupal-->>-Akamai2: Application page
  Akamai2-->>-Prerender: (return)
  Prerender-->Prerender: Execute Application
  Prerender-->Prerender: prerender-status-code set to 404
  Prerender-->>-Akamai1: 404 status code
  Akamai1-->Akamai1: Fancy 404 message
  Akamai1-->>-GoogleBing: (return)

Related

Dictionary Request Forwarding