Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Don't bake server-side 'now' into cacheable rendered output
Align caching and revalidation with time-dependent rendered data; avoid embedding an unbounded notion of now into long-lived shared output.
Bad example
| 1 | const events = await provider.getEvents({ date: new Date().getTime() }); // server time, gets cached |
Explanation (EN)
A cached now-dependent representation can outlive the time interval it describes.
Objašnjenje (HR)
Good example
| 1 | const bucket = Math.floor(Date.now() / freshnessWindowMs); |
| 2 | const events = await eventCache.getOrLoad({ bucket, filters }); |
Explanation (EN)
The time bucket is part of an explicitly bounded freshness contract; the cache and page revalidation must share that contract.
Objašnjenje (HR)
Notes (EN)
When rendering time-sensitive data into shared cached output, define its time granularity and freshness budget, then select revalidation, an explicit validated time bucket or uncached rendering.
Exceptions / Tradeoffs (EN)
Client fetching is optional, not a universal requirement. A fresh timestamp query on every request destroys reuse and client time must not control authorization or trusted server decisions.