Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
blittle committed Jul 19, 2023
1 parent 2fc4886 commit 7d1dbbf
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/hydrogen/src/foundation/Cache/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,21 @@ export async function setItemInCache(
const cacheControl = getCacheControlSetting(userCacheOptions);

// The padded cache-control to mimic stale-while-revalidate
request.headers.set(
'cache-control',
generateDefaultCacheControlHeader(
getCacheControlSetting(cacheControl, {
maxAge:
(cacheControl.maxAge || 0) + (cacheControl.staleWhileRevalidate || 0),
})
)
const paddedCacheControlString = generateDefaultCacheControlHeader(
getCacheControlSetting(cacheControl, {
maxAge:
(cacheControl.maxAge || 0) + (cacheControl.staleWhileRevalidate || 0),
})
);

// The cache-control we want to set on response
const cacheControlString = generateDefaultCacheControlHeader(
getCacheControlSetting(cacheControl)
);

// CF will override cache-control, so we need to keep a
// non-modified real-cache-control
response.headers.set('cache-control', paddedCacheControlString);
response.headers.set('real-cache-control', cacheControlString);
response.headers.set('cache-put-date', new Date().toUTCString());

Expand Down

0 comments on commit 7d1dbbf

Please sign in to comment.