Skip to content

Commit

Permalink
fix(storefront): Dropping apiContext.timestamp to support etag cach…
Browse files Browse the repository at this point in the history
…ing on output HTML
  • Loading branch information
leomp12 committed Oct 23, 2024
1 parent 27861d3 commit 6231f2d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
4 changes: 0 additions & 4 deletions packages/storefront/src/lib/$storefront.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ import type { CustomSharedData } from '@@sf/custom-shared-data';
export type StorefrontApiContext = {
resource: 'products',
doc: Products,
timestamp: number,
} | {
resource: 'categories',
doc: Categories,
timestamp: number,
} | {
resource: 'brands',
doc: Brands,
timestamp: number,
} | {
resource: 'collections',
doc: Collections,
timestamp: number,
};

export type $Storefront = {
Expand Down
2 changes: 1 addition & 1 deletion packages/storefront/src/lib/layouts/BaseHead.astro
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ window._firstLoadContextId = '${apiDoc._id}';`;
$storefront.apiContext = ${JSON.stringify({
resource: apiContext.resource,
doc: minifyApiDoc({ ...apiDoc }),
timestamp: Date.now(),
// timestamp: Date.now(),
})};
$storefront.context /* DEPRECATED */ = $storefront.apiContext;
_emitApiContext('${apiDoc._id}');`;
Expand Down
1 change: 0 additions & 1 deletion packages/storefront/src/lib/ssr-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ const loadRouteContext = async (
sessions[sid].apiContext = {
resource: apiResource,
doc: apiDoc,
timestamp: Date.now(),
};
sessions[sid]._timer = setTimeout(() => {
// @ts-expect-error: mem clearing
Expand Down

0 comments on commit 6231f2d

Please sign in to comment.