Commit bc357a4
authored
Add Cache-Control to the commit API route (#8580)
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0)
(oldest at bottom):
* #8584
* #8582
* __->__ #8580
* #8579
* #8578
* #8576
**Impact:** HUD commit page consumers (CDN-cached reads)
**Risk:** low
## What
Set a short-TTL `Cache-Control` header (`s-maxage=60,
stale-while-revalidate=240`) on the
`/api/[repoOwner]/[repoName]/commit/[sha]` endpoint, which previously
sent no caching headers.
## Why
The commit endpoint calls into GitHub via `fetchCommit`, and every
repeat view hit the origin, adding to the shared PyTorchBot
installation's rate-limit budget. Caching at the CDN collapses repeat
views of the same sha to at most one origin call per minute. The TTL is
kept short because the response mixes immutable commit metadata with
live CI job data that must stay fresh.
Signed-off-by: Jean Schmidt <contato@jschmidt.me>1 parent 8fd31c1 commit bc357a4
1 file changed
Lines changed: 10 additions & 11 deletions
Lines changed: 10 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
33 | 32 | | |
0 commit comments