Diffinery

homeflare/celldpublic

celld/docs/services/static-assets-flow.svg
185 lines · 12.5 KBRaw History
1<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 456 690" 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
4than GET or HEAD leaves at once and the Worker answers. A path that
5run_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,
7302, 303, 307, or 308 gives a Location header with no body, and status 200
8restarts routing at the destination path. html_handling then looks for a file:
9the exact path gives 200 with the body, and another spelling gives 307 to the
10canonical path. After a miss the node re-reads the deployment pointer, at most
11once in five seconds, so a newer deployment can still answer. not_found_handling
12fabricates the last answer, but only for a navigation request or for a
13deployment with no Worker: single-page-application returns /index.html with 200,
14and 404-page returns the nearest 404.html with 404. When nothing matches the
15Worker answers, and a deployment with no Worker answers 404. A green outcome
16comes from the asset layer and a grey outcome comes from the Worker. Separately,
17a missing or corrupt asset body gives 502 and never falls through to the
18Worker.</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="5" refY="5" markerWidth="10"
49 markerHeight="10" markerUnits="userSpaceOnUse" orient="auto-start-reverse">
50 <path class="d-acc" fill="none" stroke="currentColor" stroke-width="1" d="M1 1 L5 5 L1 9" />
51 </marker>
52 <marker id="sa-arrow-acc" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="10"
53 markerHeight="10" markerUnits="userSpaceOnUse" orient="auto-start-reverse">
54 <path class="d-acc" fill="none" stroke="currentColor" stroke-width="1" d="M1 1 L5 5 L1 9" />
55 </marker>
56 </defs>
57
58 <!-- One request enters the column of tests. -->
59 <rect class="d-panel" x="8" y="8" width="228" height="32" fill="currentColor" />
60 <rect class="d-ink" x="8" y="8" width="228" height="32" fill="none" stroke="currentColor" stroke-width="1" />
61 <text class="d-ink" x="122" y="28.5" fill="currentColor" text-anchor="middle">One request reaches a node</text>
62 <text class="d-faint sm" x="358" y="29" fill="currentColor" text-anchor="middle">who answers, and with what</text>
63
64 <path class="d-acc" d="M122 40 V61" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
65
66 <!-- The method test: only GET and HEAD can reach an asset. -->
67 <rect class="d-panel" x="8" y="62" width="228" height="40" fill="currentColor" />
68 <rect class="d-faint" x="8" y="62" width="228" height="40" fill="none" stroke="currentColor" />
69 <text class="d-ink" x="20" y="86.5" fill="currentColor">Method other than GET or HEAD</text>
70 <path class="d-acc" d="M236 82 H267" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
71 <rect class="d-sunk" x="268" y="62" width="180" height="40" fill="currentColor" />
72 <rect class="d-soft" x="268" y="62" width="180" height="40" fill="none" stroke="currentColor" />
73 <text class="d-ink sm" x="278" y="86" fill="currentColor">the Worker answers</text>
74
75 <path class="d-acc" d="M122 102 V123" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
76
77 <!-- run_worker_first inverts the order for the paths it names. -->
78 <rect class="d-panel" x="8" y="124" width="228" height="40" fill="currentColor" />
79 <rect class="d-faint" x="8" y="124" width="228" height="40" fill="none" stroke="currentColor" />
80 <text class="d-ink mono" x="20" y="141" fill="currentColor">run_worker_first</text>
81 <text class="d-faint sm" x="20" y="155" fill="currentColor">true, or up to 100 patterns</text>
82 <path class="d-acc" d="M236 144 H267" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
83 <rect class="d-sunk" x="268" y="124" width="180" height="40" fill="currentColor" />
84 <rect class="d-soft" x="268" y="124" width="180" height="40" fill="none" stroke="currentColor" />
85 <text class="d-ink sm" x="278" y="141" fill="currentColor">the Worker answers</text>
86 <text class="d-faint sm" x="278" y="155" fill="currentColor">no asset lookup at all</text>
87
88 <path class="d-acc" d="M122 164 V185" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
89
90 <!-- _redirects runs before any file lookup. -->
91 <rect class="d-panel" x="8" y="186" width="228" height="80" fill="currentColor" />
92 <rect class="d-faint" x="8" y="186" width="228" height="80" fill="none" stroke="currentColor" />
93 <text class="d-ink mono" x="20" y="223" fill="currentColor">_redirects</text>
94 <text class="d-faint sm" x="20" y="237" fill="currentColor">file order, first match wins</text>
95 <g class="d-acc" fill="none" stroke="currentColor" stroke-width="1">
96 <path d="M236 226 H252" />
97 <path d="M252 204 V248" />
98 <path d="M252 204 H267" marker-end="url(#sa-arrow-acc)" />
99 <path d="M252 248 H267" marker-end="url(#sa-arrow-acc)" />
100 </g>
101 <rect class="d-tint" x="268" y="186" width="180" height="36" fill="currentColor" />
102 <rect class="d-acc" x="268" y="186" width="180" height="36" fill="none" stroke="currentColor" />
103 <text class="d-ink sm" x="278" y="201" fill="currentColor">301 302 303 307 308</text>
104 <text class="d-faint sm" x="278" y="215" fill="currentColor">a Location, no body</text>
105 <rect class="d-tint" x="268" y="230" width="180" height="36" fill="currentColor" />
106 <rect class="d-acc" x="268" y="230" width="180" height="36" fill="none" stroke="currentColor" />
107 <text class="d-ink sm" x="278" y="245" fill="currentColor">200</text>
108 <text class="d-faint sm" x="278" y="259" fill="currentColor">restart at the destination</text>
109
110 <path class="d-acc" d="M122 266 V303" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
111 <path class="d-acc" d="M284 266 V282 H127" fill="none" stroke="currentColor" stroke-width="1" stroke-dasharray="4 3" marker-end="url(#sa-arrow-acc)" />
112
113 <!-- html_handling chooses which file a path can reach. -->
114 <rect class="d-panel" x="8" y="304" width="228" height="80" fill="currentColor" />
115 <rect class="d-faint" x="8" y="304" width="228" height="80" fill="none" stroke="currentColor" />
116 <text class="d-ink mono" x="20" y="341" fill="currentColor">html_handling</text>
117 <text class="d-faint sm" x="20" y="355" fill="currentColor">auto, force, drop, or none</text>
118 <g class="d-acc" fill="none" stroke="currentColor" stroke-width="1">
119 <path d="M236 344 H252" />
120 <path d="M252 322 V366" />
121 <path d="M252 322 H267" marker-end="url(#sa-arrow-acc)" />
122 <path d="M252 366 H267" marker-end="url(#sa-arrow-acc)" />
123 </g>
124 <rect class="d-tint" x="268" y="304" width="180" height="36" fill="currentColor" />
125 <rect class="d-acc" x="268" y="304" width="180" height="36" fill="none" stroke="currentColor" />
126 <text class="d-ink sm" x="278" y="319" fill="currentColor">the canonical path</text>
127 <text class="d-faint sm" x="278" y="333" fill="currentColor">200 with the body</text>
128 <rect class="d-tint" x="268" y="348" width="180" height="36" fill="currentColor" />
129 <rect class="d-acc" x="268" y="348" width="180" height="36" fill="none" stroke="currentColor" />
130 <text class="d-ink sm" x="278" y="363" fill="currentColor">another spelling</text>
131 <text class="d-faint sm" x="278" y="377" fill="currentColor">307 to the canonical path</text>
132
133 <path class="d-acc" d="M122 384 V405" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
134
135 <!-- The step Cloudflare does not need: a rolling restart leaves nodes on
136 different indexes, so a miss re-reads the pointer. -->
137 <rect class="d-panel" x="8" y="406" width="228" height="44" fill="currentColor" />
138 <rect class="d-faint" x="8" y="406" width="228" height="44" fill="none" stroke="currentColor" />
139 <text class="d-ink" x="20" y="425.5" fill="currentColor">Miss: re-read the pointer</text>
140 <text class="d-faint sm" x="20" y="439.5" fill="currentColor">at most once in five seconds</text>
141 <path class="d-acc" d="M236 428 H267" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow-acc)" />
142 <rect class="d-tint" x="268" y="406" width="180" height="44" fill="currentColor" />
143 <rect class="d-acc" x="268" y="406" width="180" height="44" fill="none" stroke="currentColor" />
144 <text class="d-ink sm" x="278" y="425" fill="currentColor">a newer deployment has it</text>
145 <text class="d-faint sm" x="278" y="439" fill="currentColor">200 with the body</text>
146
147 <path class="d-acc" d="M122 450 V471" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
148
149 <!-- not_found_handling fabricates a response, but not for every request. -->
150 <rect class="d-panel" x="8" y="472" width="228" height="80" fill="currentColor" />
151 <rect class="d-faint" x="8" y="472" width="228" height="80" fill="none" stroke="currentColor" />
152 <text class="d-ink mono" x="20" y="509" fill="currentColor">not_found_handling</text>
153 <text class="d-faint sm" x="20" y="523" fill="currentColor">navigation, or no Worker</text>
154 <g class="d-acc" fill="none" stroke="currentColor" stroke-width="1">
155 <path d="M236 512 H252" />
156 <path d="M252 490 V534" />
157 <path d="M252 490 H267" marker-end="url(#sa-arrow-acc)" />
158 <path d="M252 534 H267" marker-end="url(#sa-arrow-acc)" />
159 </g>
160 <rect class="d-tint" x="268" y="472" width="180" height="36" fill="currentColor" />
161 <rect class="d-acc" x="268" y="472" width="180" height="36" fill="none" stroke="currentColor" />
162 <text class="d-ink sm" x="278" y="487" fill="currentColor">single-page-application</text>
163 <text class="d-faint sm" x="278" y="501" fill="currentColor">/index.html, 200</text>
164 <rect class="d-tint" x="268" y="516" width="180" height="36" fill="currentColor" />
165 <rect class="d-acc" x="268" y="516" width="180" height="36" fill="none" stroke="currentColor" />
166 <text class="d-ink sm" x="278" y="531" fill="currentColor">404-page</text>
167 <text class="d-faint sm" x="278" y="545" fill="currentColor">the nearest 404.html, 404</text>
168
169 <path class="d-acc" d="M122 552 V573" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
170
171 <!-- The asset layer has no answer left. -->
172 <rect class="d-panel" x="8" y="574" width="228" height="44" fill="currentColor" />
173 <rect class="d-ink" x="8" y="574" width="228" height="44" fill="none" stroke="currentColor" stroke-width="1" />
174 <text class="d-ink" x="20" y="600.5" fill="currentColor">Nothing matched</text>
175 <path class="d-acc" d="M236 596 H267" fill="none" stroke="currentColor" stroke-width="1" marker-end="url(#sa-arrow)" />
176 <rect class="d-sunk" x="268" y="574" width="180" height="44" fill="currentColor" />
177 <rect class="d-soft" x="268" y="574" width="180" height="44" fill="none" stroke="currentColor" />
178 <text class="d-ink sm" x="278" y="593" fill="currentColor">the Worker answers</text>
179 <text class="d-faint sm" x="278" y="607" fill="currentColor">no Worker: 404</text>
180
181 <!-- The one outcome that never reaches the Worker. -->
182 <rect class="d-faint" x="8" y="640" width="440" height="42" fill="none" stroke="currentColor" stroke-dasharray="5 4" />
183 <text class="d-ink sm" x="20" y="658" fill="currentColor">A missing or corrupt asset body gives 502.</text>
184 <text class="d-faint sm" x="20" y="672" fill="currentColor">The request never falls through to the Worker.</text>
185</svg>