Skip to content

Commit

Permalink
Update README and documentation to reflect Next.js version compatibil…
Browse files Browse the repository at this point in the history
…ity and default expire age calculation adjustments
  • Loading branch information
better-salmon committed Nov 26, 2024
1 parent f777d8d commit b46ca76
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-boxes-build.md
Original file line number Diff line number Diff line change
@@ -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`.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions docs/cache-handler-docs/src/pages/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cache-handler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/cache-handler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"typescript": "5.7.2"
},
"peerDependencies": {
"next": ">= 13.5.1",
"next": ">= 13.5.1 < 15",
"redis": ">= 4.6"
},
"distTags": [
Expand Down
2 changes: 1 addition & 1 deletion packages/cache-handler/src/cache-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit b46ca76

Please sign in to comment.