| 1 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 440 674" role="img" aria-labelledby="assetsFlowTitle assetsFlowDesc"> |
| 2 | <title id="assetsFlowTitle">How celld decides between an asset and the Worker</title> |
| 3 | <desc id="assetsFlowDesc">A request reaches a node and passes down a column of tests. A method other |
| 4 | than GET or HEAD leaves at once and the Worker answers. A path that |
| 5 | run_worker_first matches also leaves, and no asset lookup happens. The |
| 6 | _redirects rules run next, in file order, and the first match wins: status 301, |
| 7 | 302, 303, 307, or 308 gives a Location header with no body, and status 200 |
| 8 | restarts routing at the destination path. html_handling then looks for a file: |
| 9 | the exact path gives 200 with the body, and another spelling gives 307 to the |
| 10 | canonical path. After a miss the node re-reads the deployment pointer, at most |
| 11 | once in five seconds, so a newer deployment can still answer. not_found_handling |
| 12 | fabricates the last answer, but only for a navigation request or for a |
| 13 | deployment with no Worker: single-page-application returns /index.html with 200, |
| 14 | and 404-page returns the nearest 404.html with 404. When nothing matches the |
| 15 | Worker answers, and a deployment with no Worker answers 404. A green outcome |
| 16 | comes from the asset layer and a grey outcome comes from the Worker. Separately, |
| 17 | a missing or corrupt asset body gives 502 and never falls through to the |
| 18 | Worker.</desc> |
| 19 | <style> |
| 20 | /* GitHub renders this file as an image, so the diagram carries literal |
| 21 | colours here. The site rules in landing/src/style.css are more specific, |
| 22 | so the documentation theme tokens win there. SVG paints text black by |
| 23 | default, and a class that sets only `color` never reaches the fill, so |
| 24 | every label sets fill="currentColor" as well. */ |
| 25 | svg { font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif; } |
| 26 | text { font-size: 12px; fill: currentColor; } |
| 27 | tspan { fill: currentColor; } |
| 28 | .sm { font-size: 11px; } |
| 29 | .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; } |
| 30 | .d-ink { color: #121212; } |
| 31 | .d-soft { color: #3d3b37; } |
| 32 | .d-faint { color: #6e6a62; } |
| 33 | .d-acc { color: #10803f; } |
| 34 | .d-panel { color: #ffffff; } |
| 35 | .d-sunk { color: #f0eee8; } |
| 36 | .d-tint { color: #d6efdf; } |
| 37 | @media (prefers-color-scheme: dark) { |
| 38 | .d-ink { color: #efede7; } |
| 39 | .d-soft { color: #c9c6be; } |
| 40 | .d-faint { color: #928e85; } |
| 41 | .d-acc { color: #3fc472; } |
| 42 | .d-panel { color: #1a1a19; } |
| 43 | .d-sunk { color: #232321; } |
| 44 | .d-tint { color: #10301d; } |
| 45 | } |
| 46 | </style> |
| 47 | <defs> |
| 48 | <marker id="sa-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"> |
| 49 | <path class="d-soft" d="M0,1 L9,5 L0,9 z" fill="currentColor" /> |
| 50 | </marker> |
| 51 | <marker id="sa-arrow-acc" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse"> |
| 52 | <path class="d-acc" d="M0,1 L9,5 L0,9 z" fill="currentColor" /> |
| 53 | </marker> |
| 54 | </defs> |
| 55 | |
| 56 | <!-- One request enters the column of tests. --> |
| 57 | <rect class="d-panel" x="8" y="8" width="228" height="32" rx="6" fill="currentColor" /> |
| 58 | <rect class="d-ink" x="8" y="8" width="228" height="32" rx="6" fill="none" stroke="currentColor" stroke-width="1.5" /> |
| 59 | <text class="d-ink" x="122" y="29" fill="currentColor" text-anchor="middle">One request reaches a node</text> |
| 60 | <text class="d-faint sm" x="342" y="29" fill="currentColor" text-anchor="middle">who answers, and with what</text> |
| 61 | |
| 62 | <path class="d-soft" d="M122,40 V62" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 63 | |
| 64 | <!-- The method test: only GET and HEAD can reach an asset. --> |
| 65 | <rect class="d-panel" x="8" y="62" width="228" height="40" rx="6" fill="currentColor" /> |
| 66 | <rect class="d-faint" x="8" y="62" width="228" height="40" rx="6" fill="none" stroke="currentColor" /> |
| 67 | <text class="d-ink" x="20" y="87" fill="currentColor">Method other than GET or HEAD</text> |
| 68 | <path class="d-soft" d="M236,82 H252" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 69 | <rect class="d-sunk" x="252" y="62" width="180" height="40" rx="6" fill="currentColor" /> |
| 70 | <rect class="d-soft" x="252" y="62" width="180" height="40" rx="6" fill="none" stroke="currentColor" /> |
| 71 | <text class="d-ink sm" x="262" y="87" fill="currentColor">the Worker answers</text> |
| 72 | |
| 73 | <path class="d-soft" d="M122,102 V124" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 74 | |
| 75 | <!-- run_worker_first inverts the order for the paths it names. --> |
| 76 | <rect class="d-panel" x="8" y="124" width="228" height="40" rx="6" fill="currentColor" /> |
| 77 | <rect class="d-faint" x="8" y="124" width="228" height="40" rx="6" fill="none" stroke="currentColor" /> |
| 78 | <text class="d-ink mono" x="20" y="143" fill="currentColor">run_worker_first</text> |
| 79 | <text class="d-faint sm" x="20" y="158" fill="currentColor">true, or up to 100 patterns</text> |
| 80 | <path class="d-soft" d="M236,144 H252" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 81 | <rect class="d-sunk" x="252" y="124" width="180" height="40" rx="6" fill="currentColor" /> |
| 82 | <rect class="d-soft" x="252" y="124" width="180" height="40" rx="6" fill="none" stroke="currentColor" /> |
| 83 | <text class="d-ink sm" x="262" y="143" fill="currentColor">the Worker answers</text> |
| 84 | <text class="d-faint sm" x="262" y="158" fill="currentColor">no asset lookup at all</text> |
| 85 | |
| 86 | <path class="d-soft" d="M122,164 V186" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 87 | |
| 88 | <!-- _redirects runs before any file lookup. --> |
| 89 | <rect class="d-panel" x="8" y="186" width="228" height="80" rx="6" fill="currentColor" /> |
| 90 | <rect class="d-faint" x="8" y="186" width="228" height="80" rx="6" fill="none" stroke="currentColor" /> |
| 91 | <text class="d-ink mono" x="20" y="218" fill="currentColor">_redirects</text> |
| 92 | <text class="d-faint sm" x="20" y="236" fill="currentColor">file order, first match wins</text> |
| 93 | <g class="d-acc" fill="none" stroke="currentColor" stroke-width="1.5"> |
| 94 | <path d="M236,226 H244" /> |
| 95 | <path d="M244,204 V248" /> |
| 96 | <path d="M244,204 H252" marker-end="url(#sa-arrow-acc)" /> |
| 97 | <path d="M244,248 H252" marker-end="url(#sa-arrow-acc)" /> |
| 98 | </g> |
| 99 | <rect class="d-tint" x="252" y="186" width="180" height="36" rx="6" fill="currentColor" /> |
| 100 | <rect class="d-acc" x="252" y="186" width="180" height="36" rx="6" fill="none" stroke="currentColor" /> |
| 101 | <text class="d-ink sm" x="262" y="204" fill="currentColor">301 302 303 307 308</text> |
| 102 | <text class="d-faint sm" x="262" y="218" fill="currentColor">a Location, no body</text> |
| 103 | <rect class="d-tint" x="252" y="230" width="180" height="36" rx="6" fill="currentColor" /> |
| 104 | <rect class="d-acc" x="252" y="230" width="180" height="36" rx="6" fill="none" stroke="currentColor" /> |
| 105 | <text class="d-ink sm" x="262" y="248" fill="currentColor">200</text> |
| 106 | <text class="d-faint sm" x="262" y="262" fill="currentColor">restart at the destination</text> |
| 107 | |
| 108 | <path class="d-soft" d="M122,266 V288" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 109 | <path class="d-acc" d="M268,266 V282 H126" fill="none" stroke="currentColor" stroke-width="1.5" stroke-dasharray="4 3" marker-end="url(#sa-arrow-acc)" /> |
| 110 | |
| 111 | <!-- html_handling chooses which file a path can reach. --> |
| 112 | <rect class="d-panel" x="8" y="288" width="228" height="80" rx="6" fill="currentColor" /> |
| 113 | <rect class="d-faint" x="8" y="288" width="228" height="80" rx="6" fill="none" stroke="currentColor" /> |
| 114 | <text class="d-ink mono" x="20" y="320" fill="currentColor">html_handling</text> |
| 115 | <text class="d-faint sm" x="20" y="338" fill="currentColor">auto, force, drop, or none</text> |
| 116 | <g class="d-acc" fill="none" stroke="currentColor" stroke-width="1.5"> |
| 117 | <path d="M236,328 H244" /> |
| 118 | <path d="M244,306 V350" /> |
| 119 | <path d="M244,306 H252" marker-end="url(#sa-arrow-acc)" /> |
| 120 | <path d="M244,350 H252" marker-end="url(#sa-arrow-acc)" /> |
| 121 | </g> |
| 122 | <rect class="d-tint" x="252" y="288" width="180" height="36" rx="6" fill="currentColor" /> |
| 123 | <rect class="d-acc" x="252" y="288" width="180" height="36" rx="6" fill="none" stroke="currentColor" /> |
| 124 | <text class="d-ink sm" x="262" y="306" fill="currentColor">the canonical path</text> |
| 125 | <text class="d-faint sm" x="262" y="320" fill="currentColor">200 with the body</text> |
| 126 | <rect class="d-tint" x="252" y="332" width="180" height="36" rx="6" fill="currentColor" /> |
| 127 | <rect class="d-acc" x="252" y="332" width="180" height="36" rx="6" fill="none" stroke="currentColor" /> |
| 128 | <text class="d-ink sm" x="262" y="350" fill="currentColor">another spelling</text> |
| 129 | <text class="d-faint sm" x="262" y="364" fill="currentColor">307 to the canonical path</text> |
| 130 | |
| 131 | <path class="d-soft" d="M122,368 V390" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 132 | |
| 133 | <!-- The step Cloudflare does not need: a rolling restart leaves nodes on |
| 134 | different indexes, so a miss re-reads the pointer. --> |
| 135 | <rect class="d-panel" x="8" y="390" width="228" height="44" rx="6" fill="currentColor" /> |
| 136 | <rect class="d-faint" x="8" y="390" width="228" height="44" rx="6" fill="none" stroke="currentColor" /> |
| 137 | <text class="d-ink" x="20" y="411" fill="currentColor">Miss: re-read the pointer</text> |
| 138 | <text class="d-faint sm" x="20" y="427" fill="currentColor">at most once in five seconds</text> |
| 139 | <path class="d-acc" d="M236,412 H252" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow-acc)" /> |
| 140 | <rect class="d-tint" x="252" y="390" width="180" height="44" rx="6" fill="currentColor" /> |
| 141 | <rect class="d-acc" x="252" y="390" width="180" height="44" rx="6" fill="none" stroke="currentColor" /> |
| 142 | <text class="d-ink sm" x="262" y="411" fill="currentColor">a newer deployment has it</text> |
| 143 | <text class="d-faint sm" x="262" y="427" fill="currentColor">200 with the body</text> |
| 144 | |
| 145 | <path class="d-soft" d="M122,434 V456" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 146 | |
| 147 | <!-- not_found_handling fabricates a response, but not for every request. --> |
| 148 | <rect class="d-panel" x="8" y="456" width="228" height="80" rx="6" fill="currentColor" /> |
| 149 | <rect class="d-faint" x="8" y="456" width="228" height="80" rx="6" fill="none" stroke="currentColor" /> |
| 150 | <text class="d-ink mono" x="20" y="488" fill="currentColor">not_found_handling</text> |
| 151 | <text class="d-faint sm" x="20" y="506" fill="currentColor">navigation, or no Worker</text> |
| 152 | <g class="d-acc" fill="none" stroke="currentColor" stroke-width="1.5"> |
| 153 | <path d="M236,496 H244" /> |
| 154 | <path d="M244,474 V518" /> |
| 155 | <path d="M244,474 H252" marker-end="url(#sa-arrow-acc)" /> |
| 156 | <path d="M244,518 H252" marker-end="url(#sa-arrow-acc)" /> |
| 157 | </g> |
| 158 | <rect class="d-tint" x="252" y="456" width="180" height="36" rx="6" fill="currentColor" /> |
| 159 | <rect class="d-acc" x="252" y="456" width="180" height="36" rx="6" fill="none" stroke="currentColor" /> |
| 160 | <text class="d-ink sm" x="262" y="474" fill="currentColor">single-page-application</text> |
| 161 | <text class="d-faint sm" x="262" y="488" fill="currentColor">/index.html, 200</text> |
| 162 | <rect class="d-tint" x="252" y="500" width="180" height="36" rx="6" fill="currentColor" /> |
| 163 | <rect class="d-acc" x="252" y="500" width="180" height="36" rx="6" fill="none" stroke="currentColor" /> |
| 164 | <text class="d-ink sm" x="262" y="518" fill="currentColor">404-page</text> |
| 165 | <text class="d-faint sm" x="262" y="532" fill="currentColor">the nearest 404.html, 404</text> |
| 166 | |
| 167 | <path class="d-soft" d="M122,536 V558" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 168 | |
| 169 | <!-- The asset layer has no answer left. --> |
| 170 | <rect class="d-panel" x="8" y="558" width="228" height="44" rx="6" fill="currentColor" /> |
| 171 | <rect class="d-ink" x="8" y="558" width="228" height="44" rx="6" fill="none" stroke="currentColor" stroke-width="1.5" /> |
| 172 | <text class="d-ink" x="20" y="585" fill="currentColor">Nothing matched</text> |
| 173 | <path class="d-soft" d="M236,580 H252" fill="none" stroke="currentColor" stroke-width="1.5" marker-end="url(#sa-arrow)" /> |
| 174 | <rect class="d-sunk" x="252" y="558" width="180" height="44" rx="6" fill="currentColor" /> |
| 175 | <rect class="d-soft" x="252" y="558" width="180" height="44" rx="6" fill="none" stroke="currentColor" /> |
| 176 | <text class="d-ink sm" x="262" y="579" fill="currentColor">the Worker answers</text> |
| 177 | <text class="d-faint sm" x="262" y="595" fill="currentColor">no Worker: 404</text> |
| 178 | |
| 179 | <!-- The one outcome that never reaches the Worker. --> |
| 180 | <rect class="d-faint" x="8" y="624" width="424" height="42" rx="6" fill="none" stroke="currentColor" stroke-dasharray="5 4" /> |
| 181 | <text class="d-ink sm" x="20" y="644" fill="currentColor">A missing or corrupt asset body gives 502.</text> |
| 182 | <text class="d-faint sm" x="20" y="659" fill="currentColor">The request never falls through to the Worker.</text> |
| 183 | </svg> |