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:
Rami Bitar
2026-07-29 11:26:23 -04:00
co-authored by Claude Fable 5
parent f23332e42c
commit 1e58ba4ca4
15 changed files with 24 additions and 81 deletions
+1 -8
View File
@@ -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;