From b46ca7634185046218ed12547593ade68879bf81 Mon Sep 17 00:00:00 2001 From: Arseny <132773930+better-salmon@users.noreply.github.com> Date: Tue, 26 Nov 2024 11:30:37 +0300 Subject: [PATCH 1/2] Update README and documentation to reflect Next.js version compatibility and default expire age calculation adjustments --- .changeset/flat-boxes-build.md | 5 +++++ README.md | 2 +- .../src/pages/api-reference/ttl-parameters.mdx | 2 +- docs/cache-handler-docs/src/pages/installation.mdx | 4 ++-- .../src/pages/usage/development-environment.mdx | 2 +- package-lock.json | 2 +- packages/cache-handler/README.md | 2 +- packages/cache-handler/package.json | 2 +- packages/cache-handler/src/cache-handler.ts | 2 +- .../src/helpers/create-validated-age-estimation-function.ts | 2 +- 10 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 .changeset/flat-boxes-build.md diff --git a/.changeset/flat-boxes-build.md b/.changeset/flat-boxes-build.md new file mode 100644 index 00000000..a1181810 --- /dev/null +++ b/.changeset/flat-boxes-build.md @@ -0,0 +1,5 @@ +--- +'@neshca/cache-handler': minor +--- + +Updated the documentation and peer dependencies to explicitly state that only Next.js versions `13.5.x` and `14.x.x` are supported. Modified the default `estimateExpireAge` function to perform the calculation as `(staleAge) => staleAge * 1.5`. diff --git a/README.md b/README.md index aa9d7e60..3d6b8b3e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Explore the versatility of `@neshca/cache-handler` in our [Examples Section](htt ## Requirements -- **Next.js**: 13.5.1 or newer. +- **Next.js**: 13.5.x or 14.x.x. - **Node.js**: 18.17.0 or newer. ## Documentation diff --git a/docs/cache-handler-docs/src/pages/api-reference/ttl-parameters.mdx b/docs/cache-handler-docs/src/pages/api-reference/ttl-parameters.mdx index ff7a5da7..41486680 100644 --- a/docs/cache-handler-docs/src/pages/api-reference/ttl-parameters.mdx +++ b/docs/cache-handler-docs/src/pages/api-reference/ttl-parameters.mdx @@ -17,7 +17,7 @@ Stale age is the time after which the cache entry is considered stale, can be se ### `estimateExpireAge` -Estimates the expiration age based on the stale age. +Estimates the expiration age based on the stale age. Defaults to `(staleAge) => staleAge * 1.5`. Expire age is the time after which the cache entry is considered expired and should be removed from the cache and must not be served. diff --git a/docs/cache-handler-docs/src/pages/installation.mdx b/docs/cache-handler-docs/src/pages/installation.mdx index 4ee47df6..66b1c282 100644 --- a/docs/cache-handler-docs/src/pages/installation.mdx +++ b/docs/cache-handler-docs/src/pages/installation.mdx @@ -7,7 +7,7 @@ This section guides you through the initial setup and basic usage of `@neshca/ca ### Prerequisites - **Node.js:** Version 18.17 or newer. -- **Next.js:** Version 13.5.1 or newer. +- **Next.js:** Version 13.5.x or 14.x.x. - **Redis (optional):** Version 4.6.0 or newer. ### Quick Start Installation @@ -100,7 +100,7 @@ pnpm create next-app --example cache-handler-redis cache-handler-redis-app ```js filename="next.config.js" copy const nextConfig = { cacheHandler: process.env.NODE_ENV === 'production' ? require.resolve('./cache-handler.mjs') : undefined, - // Use `experimental` option instead of the `cacheHandler` property when using Next.js versions from 13.5.1 to 14.0.4 + // Use `experimental` option instead of the `cacheHandler` property when using Next.js versions from 13.5.x to 14.0.4 /* experimental: { incrementalCacheHandlerPath: process.env.NODE_ENV === 'production' ? require.resolve('./cache-handler.mjs') : undefined, diff --git a/docs/cache-handler-docs/src/pages/usage/development-environment.mdx b/docs/cache-handler-docs/src/pages/usage/development-environment.mdx index 9ad77146..f26871e2 100644 --- a/docs/cache-handler-docs/src/pages/usage/development-environment.mdx +++ b/docs/cache-handler-docs/src/pages/usage/development-environment.mdx @@ -7,7 +7,7 @@ The easiest way to turn off the cache handler in a development environment is to ```js filename="next.config.js" copy const nextConfig = { cacheHandler: process.env.NODE_ENV === 'production' ? require.resolve('./cache-handler.mjs') : undefined, - // Use `experimental` option instead of the `cacheHandler` property when using Next.js versions from 13.5.1 to 14.0.4 + // Use `experimental` option instead of the `cacheHandler` property when using Next.js versions from 13.5.x to 14.0.4 /* experimental: { incrementalCacheHandlerPath: process.env.NODE_ENV === 'production' ? require.resolve('./cache-handler.mjs') : undefined, diff --git a/package-lock.json b/package-lock.json index 5b406431..0bfc0b21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17145,7 +17145,7 @@ "typescript": "5.7.2" }, "peerDependencies": { - "next": ">= 13.5.1", + "next": ">= 13.5.1 < 15", "redis": ">= 4.6" } }, diff --git a/packages/cache-handler/README.md b/packages/cache-handler/README.md index 61a5adeb..cc99515a 100644 --- a/packages/cache-handler/README.md +++ b/packages/cache-handler/README.md @@ -50,7 +50,7 @@ Explore the versatility of `@neshca/cache-handler` in our [Examples Section](htt ## Requirements -- **Next.js**: 13.5.1 or newer. +- **Next.js**: 13.5.x or 14.x.x. - **Node.js**: 18.17.0 or newer. ## Documentation diff --git a/packages/cache-handler/package.json b/packages/cache-handler/package.json index d546d40e..86967856 100644 --- a/packages/cache-handler/package.json +++ b/packages/cache-handler/package.json @@ -92,7 +92,7 @@ "typescript": "5.7.2" }, "peerDependencies": { - "next": ">= 13.5.1", + "next": ">= 13.5.1 < 15", "redis": ">= 4.6" }, "distTags": [ diff --git a/packages/cache-handler/src/cache-handler.ts b/packages/cache-handler/src/cache-handler.ts index 9089ea26..4c49b0e5 100644 --- a/packages/cache-handler/src/cache-handler.ts +++ b/packages/cache-handler/src/cache-handler.ts @@ -168,7 +168,7 @@ export type TTLParameters = { * After the stale age, the cache entry is considered stale, can be served from the cache, and should be revalidated. * Revalidation is handled by the `CacheHandler` class. * - * @default (staleAge) => staleAge + * @default (staleAge) => staleAge * 1.5 * * @returns The expiration age in seconds. * diff --git a/packages/cache-handler/src/helpers/create-validated-age-estimation-function.ts b/packages/cache-handler/src/helpers/create-validated-age-estimation-function.ts index a743293d..5535b25c 100644 --- a/packages/cache-handler/src/helpers/create-validated-age-estimation-function.ts +++ b/packages/cache-handler/src/helpers/create-validated-age-estimation-function.ts @@ -11,7 +11,7 @@ type EstimateExpireAgeFunction = typeof getInitialExpireAge; * @returns The initial expire age. */ export function getInitialExpireAge(staleAge: number): number { - return staleAge; + return staleAge * 1.5; } /** From aa2e3e14d0fc223deb975d7766f627e1f2998aa4 Mon Sep 17 00:00:00 2001 From: Arseny <132773930+better-salmon@users.noreply.github.com> Date: Tue, 26 Nov 2024 12:23:04 +0300 Subject: [PATCH 2/2] Update README and docs --- README.md | 2 +- docs/cache-handler-docs/src/pages/installation.mdx | 8 ++++---- .../src/pages/usage/development-environment.mdx | 2 +- docs/cache-handler-docs/theme.config.jsx | 14 +++----------- packages/cache-handler/README.md | 6 +++--- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3d6b8b3e..8daa8984 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Explore the versatility of `@neshca/cache-handler` in our [Examples Section](htt ## Requirements -- **Next.js**: 13.5.x or 14.x.x. +- **Next.js**: 13.5.1 or newer (below 15.0.0). - **Node.js**: 18.17.0 or newer. ## Documentation diff --git a/docs/cache-handler-docs/src/pages/installation.mdx b/docs/cache-handler-docs/src/pages/installation.mdx index 66b1c282..8e754c6d 100644 --- a/docs/cache-handler-docs/src/pages/installation.mdx +++ b/docs/cache-handler-docs/src/pages/installation.mdx @@ -6,9 +6,9 @@ This section guides you through the initial setup and basic usage of `@neshca/ca ### Prerequisites -- **Node.js:** Version 18.17 or newer. -- **Next.js:** Version 13.5.x or 14.x.x. -- **Redis (optional):** Version 4.6.0 or newer. +- **Node.js:** 18.17 or newer. +- **Next.js:** 13.5.1 or newer (below 15.0.0). +- **Redis (optional):** 4.6.0 or newer. ### Quick Start Installation @@ -100,7 +100,7 @@ pnpm create next-app --example cache-handler-redis cache-handler-redis-app ```js filename="next.config.js" copy const nextConfig = { cacheHandler: process.env.NODE_ENV === 'production' ? require.resolve('./cache-handler.mjs') : undefined, - // Use `experimental` option instead of the `cacheHandler` property when using Next.js versions from 13.5.x to 14.0.4 + // Use `experimental` option instead of the `cacheHandler` property when using Next.js versions from 13.5.1 to 14.0.4 /* experimental: { incrementalCacheHandlerPath: process.env.NODE_ENV === 'production' ? require.resolve('./cache-handler.mjs') : undefined, diff --git a/docs/cache-handler-docs/src/pages/usage/development-environment.mdx b/docs/cache-handler-docs/src/pages/usage/development-environment.mdx index f26871e2..9ad77146 100644 --- a/docs/cache-handler-docs/src/pages/usage/development-environment.mdx +++ b/docs/cache-handler-docs/src/pages/usage/development-environment.mdx @@ -7,7 +7,7 @@ The easiest way to turn off the cache handler in a development environment is to ```js filename="next.config.js" copy const nextConfig = { cacheHandler: process.env.NODE_ENV === 'production' ? require.resolve('./cache-handler.mjs') : undefined, - // Use `experimental` option instead of the `cacheHandler` property when using Next.js versions from 13.5.x to 14.0.4 + // Use `experimental` option instead of the `cacheHandler` property when using Next.js versions from 13.5.1 to 14.0.4 /* experimental: { incrementalCacheHandlerPath: process.env.NODE_ENV === 'production' ? require.resolve('./cache-handler.mjs') : undefined, diff --git a/docs/cache-handler-docs/theme.config.jsx b/docs/cache-handler-docs/theme.config.jsx index 43d633fa..434f9703 100644 --- a/docs/cache-handler-docs/theme.config.jsx +++ b/docs/cache-handler-docs/theme.config.jsx @@ -43,19 +43,11 @@ export default { ), }, banner: { - key: 'version-1.8.0', + key: 'version-1.9.0', content: (
- 🎉 Version 1.8.0 is out! Use shared cache for the Next.js Pages API routes and getServerSideProps with{' '} - - neshClassicCache - + 🎉 Version 1.9.0 is out! This is the final release supporting Next.js 13.5.1-14.x. The upcoming version + 2.0.0 will require Next.js 15.
), }, diff --git a/packages/cache-handler/README.md b/packages/cache-handler/README.md index cc99515a..c9565811 100644 --- a/packages/cache-handler/README.md +++ b/packages/cache-handler/README.md @@ -8,9 +8,9 @@ ## Latest Release -🎉 **Version 1.8.0** has been released! It now includes the [`neshClassicCache` function ↗](https://caching-tools.github.io/next-shared-cache/functions/nesh-classic-cache), that allows you to cache the results of expensive operations in the `getServerSideProps` and API routes. +🎉 **Version 1.9.0** has been released! It changes the default `estimateExpireAge` function to perform the calculation as `(staleAge) => staleAge * 1.5` to better align with the default Next.js cache behavior. -Do not forget the [`registerInitialCache` instrumentation hook ↗](https://caching-tools.github.io/next-shared-cache/usage/populating-cache-on-start), that allows the cache to be pre-populated with the initial data when the application starts. +This is the final release leading up to version 2.0.0. The upcoming version 2 will bring significant changes and will no longer support Next.js versions 13 and 14. While version 1 will still receive ongoing maintenance, it won't get any new features. Check out the [changelog](https://github.com/caching-tools/next-shared-cache/blob/canary/packages/cache-handler/CHANGELOG.md) for more details. @@ -50,7 +50,7 @@ Explore the versatility of `@neshca/cache-handler` in our [Examples Section](htt ## Requirements -- **Next.js**: 13.5.x or 14.x.x. +- **Next.js**: 13.5.1 or newer (below 15.0.0). - **Node.js**: 18.17.0 or newer. ## Documentation