Commit d85c1e3
committed
rides-v1: edge-cache the rollup endpoint (closed-window: 24h immutable)
Cold queries against `/api/rides-v1[/cells]` are ~3-4s in prod
because each fans out to ~14 year-shards on R2 + decode + filter +
stitch. Without an explicit cache, every request re-pays that cost
(Workers don't auto-cache their own responses).
Mirroring the `/api/totals` pattern (`index.ts:1232-1280`):
- Check `caches.default` by URL on entry; HIT returns immediately.
- After computing, set `Cache-Control`: 24h immutable when the query
window ends ≥5min in the past (shards are frozen), 60s otherwise
(covers cron lag + cascade-compactor write latency before the
current month closes).
- Stash in cache via `ctx.waitUntil` so the response doesn't block
on the put.
Both endpoints share the cache wrapper since they have identical
request shape (just different output structure).1 parent 678456e commit d85c1e3
1 file changed
Lines changed: 32 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1166 | 1166 | | |
1167 | 1167 | | |
1168 | 1168 | | |
1169 | | - | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
1170 | 1185 | | |
1171 | | - | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
1172 | 1189 | | |
1173 | 1190 | | |
1174 | 1191 | | |
1175 | | - | |
1176 | | - | |
1177 | | - | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
1181 | 1204 | | |
| 1205 | + | |
1182 | 1206 | | |
1183 | 1207 | | |
1184 | 1208 | | |
| |||
0 commit comments