Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: HTTP / any
httpcachingcorrectnessheaders
Do not cache error responses such as 404s
Set caching headers only on successful responses; error responses (e.g. 404) should not be cached so transient or recoverable failures aren't served from cache.
PR: hegnar-shareholders-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | @CacheTTL(60) |
| 2 | @Get(':id/profile') |
| 3 | async getProfile() { /* may 404 and get cached */ } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | it('Should not cache errors', async () => |
| 2 | api.get('/resource/1/profile').expect(404) |
| 3 | .expect((res) => expect(res.headers['cache-control']).toBeUndefined())); |
Explanation (EN)
Objašnjenje (HR)