mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-10-27 02:16:23 -04:00
fix: add cacheLife("max") to build-time cached functions and clarify throw-vs-catch caching rule
- Add `cacheLife("max")` to `getLocalImage` (OG image) and `getStaticRoutes` (sitemap) so entries are held as long as possible during prerender instead of expiring at the default TTL
- Update AGENTS.md to distinguish build-time reads (catch inside the cached function, return a fallback, use a short `cacheLife` on the error path) from request-time reads (may throw from the cached function since they never run during prerender)
- Expand the `getCachedComments` comment to explain why throwing is only safe there: a throw inside `"use cache"` during prerender fails the build even if the caller catches it
This commit is contained in:
4 files changed
+7
-2
No files matched your search
@@ -17,7 +17,8 @@ export const commentsTag = (pageSlug: string) => `comments-${pageSlug}`;
|
||||
|
||||
/**
|
||||
* Shared across server instances since it's read at request time (inside dynamic holes), not at prerender. Throws on
|
||||
* failure so an error is never cached.
|
||||
* failure so an error is never cached -- only safe because it never runs during prerender, where a throw inside
|
||||
* "use cache" fails the build even if caught.
|
||||
*/
|
||||
const getCachedComments = async (pageSlug: string): Promise<CommentWithUser[]> => {
|
||||
"use cache: remote";
|
||||
|
||||
Reference in new issue
Block a user