diff --git a/AGENTS.md b/AGENTS.md index 32c6a5f0..fdfaf4ff 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -179,6 +179,7 @@ pre: `uninstall-pre`, post: `uninstall-post` pre: `caching-pre`, post: `caching-post` - Enable Cache Components in `next.config.ts` +- Define the cache lifetime profiles and the caching on/off switch - Implement caching in appropriate components/actions - Implement Suspense boundaries and fallbacks - Memoize various lookups per-request diff --git a/CHANGELOG.md b/CHANGELOG.md index 52ad652f..4a33109d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,46 @@ # Changelog +## 1.1.1 + +_Based on Next.js 16.2.9_ + +### Summary + +Consolidated the caching configuration into a single module. The lifetime +profiles and the switch that enables caching moved out of `next.config.ts` +into `lib/cache/cache-profiles.ts`, and the environment variable that +controls caching was renamed from `CACHE_COMPONENTS_ENABLED` to +`CACHE_ENABLED`. Caching behavior is unchanged. No lab or enhancement was +added, removed, or renumbered. + +This is groundwork for hosting the app on Cloudflare Workers, which cannot +run Cache Components: the staged-render path corrupts streamed HTML there +(see opennextjs-cloudflare#1225). A Cloudflare build has to cache at the +fetch level instead, so the parts of the caching setup that don't depend on +where caching attaches now live in one module that both approaches can +share. + +### Changes + +- Added `lib/cache/cache-profiles.ts`, holding the `standard` and `extended` + lifetime profiles, the zero-second profile used when caching is off, and + the `cacheProfile()` lookup each `use cache` boundary now calls. `cacheLife` + accepts an inline `{ stale, revalidate, expire }` object as well as a named + profile, so the `cacheLife` block and its helpers were removed from + `next.config.ts`. Folded into the caching enhancement, which is where the + module is introduced. +- Added a `CacheLifetimeProfile` interface and `CACHE_PROFILE_STANDARD` / + `CACHE_PROFILE_EXTENDED` constants, so profiles are typed and selected by + constant rather than by a bare string. All three lifetime fields are + required, unlike Next's own `CacheLife`, where each is optional. +- Renamed `CACHE_COMPONENTS_ENABLED` to `CACHE_ENABLED`. The old name + described the `cacheComponents` flag it worked around; the variable now + simply turns caching on and off. Folded into the caching enhancement's + step, alongside the `.env.example` entry. +- Converted the `cacheLife` call sites in the customers and App Extension + enhancements to the new `cacheProfile()` form, each folded into the code + commit that introduced that call. + ## 1.1.0 _Based on Next.js 16.2.9_ diff --git a/docs/TUTORIAL.md b/docs/TUTORIAL.md index dcbf2046..55a1a294 100644 --- a/docs/TUTORIAL.md +++ b/docs/TUTORIAL.md @@ -1,7 +1,7 @@ # Lab Tutorial: BigCommerce Single-Click App Starter -> **Based on version 1.1.0** — this tutorial corresponds to the latest -> progressive history tagged `1.1.0`. +> **Based on version 1.1.1** — this tutorial corresponds to the latest +> progressive history tagged `1.1.1`. This document lists the lab exercises and their step-by-step diffs. Each main-lab step links to a comparison between the step's `*-pre` (TODO diff --git a/package.json b/package.json index 428b2c23..2f8db332 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "starter-sc-app-next", - "version": "1.1.0", + "version": "1.1.1", "private": true, "packageManager": "pnpm@11.5.0", "engines": { diff --git a/src/lib/cache/cache-profiles.ts b/src/lib/cache/cache-profiles.ts index 4f75792f..0cb85e4e 100644 --- a/src/lib/cache/cache-profiles.ts +++ b/src/lib/cache/cache-profiles.ts @@ -1,7 +1,6 @@ // The app's cache lifetime profiles, and the switch that turns caching on and // off. Every `use cache` boundary selects one by calling // `cacheLife(cacheProfile(CACHE_PROFILE_STANDARD))`. -// // A cache lifetime, in seconds. Structurally compatible with Next's own // CacheLife type, but all three fields are required: every profile here sets