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
@@ -2,7 +2,6 @@ import { parseCollectionParams, type StorefrontApi } from "@shopify/hydrogen";
import 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 { CollectionBrowser } from "@/components/CollectionBrowser";
import { SEARCH_QUERY } from "@/lib/queries";
@@ -37,10 +36,6 @@ type SearchNode = NonNullable<
type SearchProductNode = Extract<SearchNode, { __typename: "Product" }>;
async function fetchSearch(term: string, searchString: string): Promise<SearchResult> {
"use cache";
cacheLife("minutes");
cacheTag("products");
if (!term) {
return {
term: "",
@@ -51,9 +46,7 @@ async function fetchSearch(term: string, searchString: string): Promise<SearchRe
};
}
// 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 searchParams = new URLSearchParams(searchString);
const browse = parseCollectionParams(searchParams);
// parseCollectionParams returns a ProductCollectionSortKeys; search only