Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Do not cache error responses such as 404s
Prevent unintended caching of transient or sensitive errors with an explicit policy; allow deliberate bounded negative caching where the API contract requires it.
Bad example
| 1 | @CacheTTL(60) |
| 2 | @Get(':id/profile') |
| 3 | async getProfile() { /* may 404 and get cached */ } |
Explanation (EN)
A transient error cached under the success TTL can keep failing after the source recovers.
Objašnjenje (HR)
Good example
| 1 | res.setHeader('Cache-Control', 'no-store'); |
| 2 | return res.status(503).json({ error: 'Temporarily unavailable' }); |
Explanation (EN)
An explicit no-store policy prevents this transient failure from being stored as a normal successful representation.
Objašnjenje (HR)
Notes (EN)
For transient failures or sensitive error responses, explicitly prohibit storage and ensure a success-only cache policy is not applied before error handling.
Exceptions / Tradeoffs (EN)
HTTP permits intentional negative caching such as a bounded public 404. Absence of Cache-Control does not prove a response will not be cached heuristically.