Prerender: Dictionary Request Forwarding - NCIOCPL/cgov-digital-platform GitHub Wiki
Standard Users
In order to minimize the number of dynamic requests to Drupal, Akamai forwarding rules are created to route all valid routes for a given application are routed to the same path on the origin server. All other routes for the application are forwarded to an application-specific "not found" location.
Valid Routes
By design, the glossary and drug dictionary applications use the same set of valid routes. In addition to the application's base URL, valid routes are:
def/*
expand/*
search/*
ampliar/*
buscar/*
These routes apply to both the English and Spanish versions.
Note: The Drug Dictionary is English-only. The ampliar
and buscar
routes are not valid.
flowchart LR
start((Request))
requestPath{Glossary/Drug path?}
start-->requestPath
subgraph drugDict [ Drug Dictionary ]
drugDictionary[ /publications/dictionaries/cancer-drug/* ]
drugDictionaryValidPath{ Known route? }
drugDictionary-->drugDictionaryValidPath
drugDictionaryKnownRoute[ Rewrite path to <br> /publications/dictionaries/cancer-drug ]
drugDictionaryUnknownRoute[ Rewrite path to <br> /publications/dictionaries/cancer-drug/404 ]
drugDictionaryValidPath--Yes-->drugDictionaryKnownRoute
drugDictionaryValidPath--No-->drugDictionaryUnknownRoute
end
subgraph spanishGenetics [ Spanish Genetics Dictionary ]
spanishGeneticsDictionary[ /espanol/publicaciones/diccionarios/diccionario-genetica/* ]
spanishGeneticsDictionaryValidPath{ Known route? }
spanishGeneticsDictionary-->spanishGeneticsDictionaryValidPath
spanishGeneticsDictionaryKnownRoute[ Rewrite path to <br> /espanol/publicaciones/diccionarios/diccionario-genetica ]
spanishGeneticsDictionaryUnknownRoute[ Rewrite path to <br> /espanol/publicaciones/diccionarios/diccionario-genetica/404 ]
spanishGeneticsDictionaryValidPath--Yes-->spanishGeneticsDictionaryKnownRoute
spanishGeneticsDictionaryValidPath--No-->spanishGeneticsDictionaryUnknownRoute
end
subgraph englishGenetics [ English Genetics Dictionary ]
geneticsDictionary[ /publications/dictionaries/genetics-dictionary/* ]
geneticsDictionaryValidPath{ Known route? }
geneticsDictionary-->geneticsDictionaryValidPath
geneticsDictionaryKnownRoute[ Rewrite path to <br> /publications/dictionaries/genetics-dictionary ]
geneticsDictionaryUnknownRoute[ Rewrite path to <br> /publications/dictionaries/genetics-dictionary/404 ]
geneticsDictionaryValidPath--Yes-->geneticsDictionaryKnownRoute
geneticsDictionaryValidPath--No-->geneticsDictionaryUnknownRoute
end
subgraph spanishDoct [ Spanish Dictionary of Cancer Terms ]
spanishGlossary[ /espanol/publicaciones/diccionarios/diccionario-cancer/* ]
spanishGlossaryValidPath{ Known route? }
spanishGlossary-->spanishGlossaryValidPath
spanishGlossaryKnownRoute[ Rewrite path to <br> /espanol/publicaciones/diccionarios/diccionario-cancer ]
spanishGlossaryUnknownRoute[ Rewrite path to <br> /espanol/publicaciones/diccionarios/diccionario-cancer/404 ]
spanishGlossaryValidPath--Yes-->spanishGlossaryKnownRoute
spanishGlossaryValidPath--No-->spanishGlossaryUnknownRoute
end
subgraph englishDoct [ English Dictionary of Cancer Terms ]
englishGlossary[ /publications/dictionaries/cancer-terms/* ]
englishGlossaryValidPath{ Known route? }
englishGlossary-->englishGlossaryValidPath
englishGlossaryKnownRoute[ Rewrite path to <br> /publications/dictionaries/cancer-terms ]
englishGlossaryUnknownRoute[ Rewrite path to <br> /publications/dictionaries/cancer-terms/404 ]
englishGlossaryValidPath--Yes-->englishGlossaryKnownRoute
englishGlossaryValidPath--No-->englishGlossaryUnknownRoute
end
requestPath-->englishGlossary
requestPath-->spanishGlossary
requestPath-->geneticsDictionary
requestPath-->spanishGeneticsDictionary
requestPath-->drugDictionary
Prerendering
When dictionary pages are requested by a user identified as Googlebot or Bingbot (or other presently unspecified crawler), the request is forwarded according to the specific route, relative to the application's root path.
- The
/
(application root, not site),/def/*
,/expand/*
, and/ampliar/*
routes are forwarded to the prerender service. - The
/search
route is forwarded to the application root on Drupal. - All other paths are routed to the same "Not found" path as non-prerendered requests.
- Notably, this set of paths includes
/def
,/expand
, and/ampliar
when they are the final path segments. - Additionally, the drug dictionary has no
/ampliar
or/ampliar/*
route.
- Notably, this set of paths includes
flowchart LR
start((Request))
crawlerDetect{ Is GoogleBing? }
start-->crawlerDetect
standardUser([ Use standard<br> user workflow ])
crawlerDetect--No-->standardUser
prerenderBot[ Is a Prerender Bot ]
crawlerDetect--Yes-->prerenderBot
detectDictionaries{ Is this a dictionary URL? }
prerenderBot-->detectDictionaries
notDictionary([ Drupal request ])
detectDictionaries--No-->notDictionary
routeDetect{ What route? }
detectDictionaries--Yes-->routeDetect
invalidRoutes[ Invalid Routes ]
searchRoutes[ /search route ]
renderableRoutes[ Preender eligible ]
routeDetect-->invalidRoutes
routeDetect-->searchRoutes
routeDetect-->renderableRoutes
subgraph invalid [ Invalid routes ]
drugDoct404[ Rewrite path to <br> /publications/dictionaries/cancer-drug/404 ]
spanishGenetic404[ Rewrite path to <br> /espanol/publicaciones/diccionarios/diccionario-genetica/404 ]
englishGenetic404[ Rewrite path to <br> /publications/dictionaries/genetics-dictionary/404 ]
spanishDoct404[ Rewrite path to <br> /espanol/publicaciones/diccionarios/diccionario-cancer/404 ]
englishDoct404[ Rewrite path to <br> /publications/dictionaries/cancer-terms/404 ]
end
subgraph search [ /search route ]
drugDictionary[ Rewrite path to <br> /publications/dictionaries/cancer-drug ]
spanishGenetic[ Rewrite path to <br> /espanol/publicaciones/diccionarios/diccionario-genetica ]
englishGenetic[ Rewrite path to <br> /publications/dictionaries/genetics-dictionary ]
spanishDoct[ Rewrite path to <br> /espanol/publicaciones/diccionarios/diccionario-cancer ]
englishDoct[ Rewrite path to <br> /publications/dictionaries/cancer-terms ]
end
subgraph prerender [ Forward to prerender.io ]
renderRoute["
/publications/dictionaries/cancer-terms
/publications/dictionaries/cancer-terms/def/*
/publications/dictionaries/cancer-terms/expand/*
/publications/dictionaries/cancer-terms/ampliar/*
/espanol/publicaciones/diccionarios/diccionario-cancer
/espanol/publicaciones/diccionarios/diccionario-cancer/def/*
/espanol/publicaciones/diccionarios/diccionario-cancer/expand/*
/espanol/publicaciones/diccionarios/diccionario-cancer/ampliar/*
/publications/dictionaries/genetics-dictionary
/publications/dictionaries/genetics-dictionary/def/*
/publications/dictionaries/genetics-dictionary/expand/*
/publications/dictionaries/genetics-dictionary/ampliar/*
/espanol/publicaciones/diccionarios/diccionario-genetica
/espanol/publicaciones/diccionarios/diccionario-genetica/def/*
/espanol/publicaciones/diccionarios/diccionario-genetica/expand/*
/espanol/publicaciones/diccionarios/diccionario-genetica/ampliar/*
/publications/dictionaries/cancer-drug
/publications/dictionaries/cancer-drug/def/*
/publications/dictionaries/cancer-drug/expand/*
"]
doPrerender[ Forward to Prerender ]
renderRoute-->doPrerender
end
renderableRoutes-->renderRoute
searchRoutes-- /publications/dictionaries/cancer-drug/search -->drugDictionary
searchRoutes-- /espanol/publicaciones/diccionarios/diccionario-genetica/search -->spanishGenetic
searchRoutes-- /publications/dictionaries/genetics-dictionary/search -->englishGenetic
searchRoutes-- /espanol/publicaciones/diccionarios/diccionario-cancer/search -->spanishDoct
searchRoutes-- /publications/dictionaries/cancer-terms/search -->englishDoct
invalidRoutes-- Invalid drug dictionary route -->drugDoct404
invalidRoutes-- Invalid Spanish Genetics route -->spanishGenetic404
invalidRoutes-- Invalid Genetics route -->englishGenetic404
invalidRoutes-- Invalid Spanish Dictionary route -->spanishDoct404
invalidRoutes-- Invalid English dictionary route -->englishDoct404