Template
Remove next/cache usage (use cache, cacheLife, cacheTag, cacheComponents)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F22Ms5Cxam5UHyxaCrtZzu
This commit is contained in:
co-authored by
Claude Fable 5
parent
f23332e42c
commit
1e58ba4ca4
@@ -1,7 +1,6 @@
|
||||
import { parseCollectionParams, type AvailableFilter } from "@shopify/hydrogen";
|
||||
import type { ProductFilter as StorefrontApiProductFilter } from "@shopify/hydrogen/storefront-api-types";
|
||||
import type { Metadata } from "next";
|
||||
import { cacheLife, cacheTag } from "next/cache";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { CollectionBrowser } from "@/components/CollectionBrowser";
|
||||
@@ -43,13 +42,7 @@ async function fetchCollection(
|
||||
availableFilters: AvailableFilter[];
|
||||
pageInfo: { hasNextPage: boolean; endCursor?: string | null };
|
||||
}> {
|
||||
"use cache";
|
||||
cacheLife("minutes");
|
||||
cacheTag("collections", "products");
|
||||
|
||||
// Reconstruct URLSearchParams from the serialized search string. `use cache`
|
||||
// serializes arguments, so a URLSearchParams passed in loses `.get` — pass a
|
||||
// plain string across the cache boundary and parse inside.
|
||||
// Reconstruct URLSearchParams from the serialized search string.
|
||||
const browse = parseCollectionParams(new URLSearchParams(searchString));
|
||||
const result = await query(handle, after, browse.filters, browse.sortKey, browse.reverse);
|
||||
return result;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { Metadata } from "next";
|
||||
import { cacheLife, cacheTag } from "next/cache";
|
||||
import Link from "next/link";
|
||||
|
||||
import { Breadcrumbs } from "@/components/Breadcrumbs";
|
||||
@@ -21,10 +20,6 @@ export const metadata: Metadata = {
|
||||
};
|
||||
|
||||
async function fetchCollections(after?: string) {
|
||||
"use cache";
|
||||
cacheLife("hours");
|
||||
cacheTag("collections");
|
||||
|
||||
const { data, errors } = await staticStorefrontClient.graphql(COLLECTIONS_QUERY, {
|
||||
variables: { first: 24, after },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user