use cache: remote
use cache
await connection()
await cookies()
await headers()
1async function getProductPrice(id: string) { 2 'use cache: remote'; 3 cacheTag(`price-${id}`); 4 return await db.query(...); 5} 6 7async function ProductPrice({ id }: { id: string }) { 8 // Ensure dynamic context 9 await connection(); 10 const price = await getProductPrice(id); 11 return <div>Price: ${price}</div>; 12} 13 14export default async function Page() { 15 return ( 16 <Suspense fallback={<Skeleton />}> 17 <ProductPrice id="1" /> 18 </Suspense> 19 ); 20}
getData()
getProductPrice()
cacheTag()
Remote cache persists across requests even after dynamic APIs are used.