Skip to content

Commit 6bae69a

Browse files
Update README and documentation and the default expire age calculation (#879)
- **New Features** - Updated the default behavior of the `estimateExpireAge` function to calculate expiration as `(staleAge) => staleAge * 1.5`. - **Documentation** - Clarified compatibility requirements for Next.js (versions `>= 13.5.1 < 15`). - Announced the release of version **1.9.0** and outlined future changes for version **2.0.0**.
1 parent f777d8d commit 6bae69a

File tree

10 files changed

+20
-23
lines changed

10 files changed

+20
-23
lines changed

.changeset/flat-boxes-build.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@neshca/cache-handler': minor
3+
---
4+
5+
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`.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Explore the versatility of `@neshca/cache-handler` in our [Examples Section](htt
2727

2828
## Requirements
2929

30-
- **Next.js**: 13.5.1 or newer.
30+
- **Next.js**: 13.5.1 or newer (below 15.0.0).
3131
- **Node.js**: 18.17.0 or newer.
3232

3333
## Documentation

docs/cache-handler-docs/src/pages/api-reference/ttl-parameters.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Stale age is the time after which the cache entry is considered stale, can be se
1717

1818
### `estimateExpireAge`
1919

20-
Estimates the expiration age based on the stale age.
20+
Estimates the expiration age based on the stale age. Defaults to `(staleAge) => staleAge * 1.5`.
2121

2222
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.
2323

docs/cache-handler-docs/src/pages/installation.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ This section guides you through the initial setup and basic usage of `@neshca/ca
66

77
### Prerequisites
88

9-
- **Node.js:** Version 18.17 or newer.
10-
- **Next.js:** Version 13.5.1 or newer.
11-
- **Redis (optional):** Version 4.6.0 or newer.
9+
- **Node.js:** 18.17 or newer.
10+
- **Next.js:** 13.5.1 or newer (below 15.0.0).
11+
- **Redis (optional):** 4.6.0 or newer.
1212

1313
### Quick Start Installation
1414

docs/cache-handler-docs/theme.config.jsx

+3-11
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,11 @@ export default {
4343
),
4444
},
4545
banner: {
46-
key: 'version-1.8.0',
46+
key: 'version-1.9.0',
4747
content: (
4848
<div>
49-
🎉 Version 1.8.0 is out! Use shared cache for the Next.js Pages API routes and getServerSideProps with{' '}
50-
<a
51-
href="/functions/nesh-classic-cache"
52-
style={{
53-
color: 'lightgreen',
54-
fontFamily: 'monospace',
55-
}}
56-
>
57-
neshClassicCache
58-
</a>
49+
🎉 Version 1.9.0 is out! This is the final release supporting Next.js 13.5.1-14.x. The upcoming version
50+
2.0.0 will require Next.js 15.
5951
</div>
6052
),
6153
},

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cache-handler/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
## Latest Release
1010

11-
🎉 **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.
11+
🎉 **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.
1212

13-
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.
13+
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.
1414

1515
Check out the [changelog](https://github.com/caching-tools/next-shared-cache/blob/canary/packages/cache-handler/CHANGELOG.md) for more details.
1616

@@ -50,7 +50,7 @@ Explore the versatility of `@neshca/cache-handler` in our [Examples Section](htt
5050

5151
## Requirements
5252

53-
- **Next.js**: 13.5.1 or newer.
53+
- **Next.js**: 13.5.1 or newer (below 15.0.0).
5454
- **Node.js**: 18.17.0 or newer.
5555

5656
## Documentation

packages/cache-handler/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"typescript": "5.7.2"
9393
},
9494
"peerDependencies": {
95-
"next": ">= 13.5.1",
95+
"next": ">= 13.5.1 < 15",
9696
"redis": ">= 4.6"
9797
},
9898
"distTags": [

packages/cache-handler/src/cache-handler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export type TTLParameters = {
168168
* After the stale age, the cache entry is considered stale, can be served from the cache, and should be revalidated.
169169
* Revalidation is handled by the `CacheHandler` class.
170170
*
171-
* @default (staleAge) => staleAge
171+
* @default (staleAge) => staleAge * 1.5
172172
*
173173
* @returns The expiration age in seconds.
174174
*

packages/cache-handler/src/helpers/create-validated-age-estimation-function.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type EstimateExpireAgeFunction = typeof getInitialExpireAge;
1111
* @returns The initial expire age.
1212
*/
1313
export function getInitialExpireAge(staleAge: number): number {
14-
return staleAge;
14+
return staleAge * 1.5;
1515
}
1616

1717
/**

0 commit comments

Comments
 (0)