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: node
cachingssrtime
Don't bake server-side 'now' into cacheable rendered output
Computing a time-dependent value (new Date()) on the server and rendering it makes the cached HTML stale; pass time as a URL/query param or fetch from the client instead.
PR: frontpage-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codejavascript
| 1 | const events = await provider.getEvents({ date: new Date().getTime() }); // server time, gets cached |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejavascript
| 1 | const date = Number(req.query.date) || undefined; // client-supplied |
| 2 | const events = date ? await provider.getEvents({ date }) : await clientFetch(); |
Explanation (EN)
Objašnjenje (HR)