Skip to content

Commit

Permalink
Fix cache control in image optimizer
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Feb 23, 2025
1 parent 1a2967e commit 158bf76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions packages/next/src/server/image-optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ export class ImageOptimizerCache {
revalidateAfter:
Math.max(maxAge, this.nextConfig.images.minimumCacheTTL) * 1000 +
Date.now(),
cacheControl: { revalidate: maxAge, expire: expireAt },
cacheControl: { revalidate: maxAge },
isStale: now > expireAt,
isFallback: false,
}
Expand Down Expand Up @@ -445,11 +445,9 @@ export class ImageOptimizerCache {
throw new InvariantError('revalidate must be a number for image-cache')
}

const expire =
cacheControl?.expire ??
Math.max(revalidate, this.nextConfig.images.minimumCacheTTL) * 1000

const expireAt = expire + Date.now()
const expireAt =
Math.max(revalidate, this.nextConfig.images.minimumCacheTTL) * 1000 +
Date.now()

try {
await writeToCacheDir(
Expand Down
2 changes: 1 addition & 1 deletion packages/next/src/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ export default class NextNodeServer extends BaseServer<
upstreamEtag,
},
isFallback: false,
revalidate: maxAge,
cacheControl: { revalidate: maxAge },
}
},
{
Expand Down

0 comments on commit 158bf76

Please sign in to comment.