代码示例(续)
// app/products/page.tsx
export default async function ProductsPage() {
// Next.js 15+ 必须显式声明 force-cache(13/14 中这是默认行为)
const res = await fetch("https://api.example.com/products", {
cache: "force-cache",
});
const products = await res.json();
return (
<div>
{products.map((product) => (
<div key={product.id}>
<h3>{product.name}</h3>
<p>${product.price}</p>
</div>
))}
</div>
);
}