Commit b619b31
authored
fix(api): correct malformed stale-while-revalidate cache header (JhaSourav07#700)
## Description
Fixes JhaSourav07#620
Fixes the malformed `Cache-Control` header in the GitHub API route by
adding an explicit numeric value for the `stale-while-revalidate`
directive.
The previous response header used:
`s-maxage=3600, stale-while-revalidate`
which is not standards-compliant and may cause inconsistent CDN/browser
caching behavior.
This PR updates the header to:
`s-maxage=3600, stale-while-revalidate=86400`
while preserving the existing cache strategy and refresh behavior.
---
## Pillar
* [x] 🛠️ Other (Bug fix, refactoring, docs)
---
## Visual Preview
N/A — this PR only modifies API caching behavior and test coverage. No
SVG/UI changes were made.
---
## Changes Made
* Fixed malformed `Cache-Control` header syntax in the GitHub API route
* Added regression tests for cache header validation
* Added test coverage for refresh cache bypass behavior
* Preserved existing API response and caching logic
---
## Validation
* `npm run format` ✅
* `npm run lint` ✅
* `npm run test` ✅ (277 tests passing)
---
## Notes
A live end-to-end header verification against the local dev server could
not be completed because GitHub credentials were not configured locally,
causing the endpoint to return a development-time `500` response.
However:
* route-level tests pass successfully
* cache header behavior is validated through automated regression tests
---
## Checklist before requesting a review:
* [x] I have read the `CONTRIBUTING.md` file.
* [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
* [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors.
* [x] My commits follow the Conventional Commits format.
* [x] I have started the repo.
* [x] I have made sure that I have only one commit to merge in this PR.2 files changed
Lines changed: 48 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
0 commit comments