File tree 3 files changed +20
-1
lines changed
packages/cache-handler/src
3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @neshca/cache-handler ' : patch
3
+ ---
4
+
5
+ Fix usage of ` cache-handler ` in dev environment
Original file line number Diff line number Diff line change @@ -260,3 +260,17 @@ SERVER_STARTED=1 npm run start
260
260
` ` `
261
261
262
262
Note that in the ` build` step you don' t need to set `SERVER_STARTED` environment variable.
263
+
264
+ ## Development environment
265
+
266
+ When you run `next dev` command, caching in Next.js works differently. It works only for `fetch` cache for App dir pages.
267
+
268
+ You can identify the development environment by checking the `process.env.NODE_ENV` variable or `onCreation` parameter.
269
+
270
+ ```js
271
+ IncrementalCache.onCreation(({ dev }) => {
272
+ if (dev) {
273
+ // ...
274
+ }
275
+ });
276
+ ```
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ export class IncrementalCache implements CacheHandler {
164
164
this . serverDistDir = context . serverDistDir ;
165
165
this . experimental = context . experimental ;
166
166
167
- if ( ! context . dev && ! IncrementalCache . cache ) {
167
+ if ( ! IncrementalCache . cache ) {
168
168
IncrementalCache . serverDistDir = this . serverDistDir ;
169
169
IncrementalCache . init ( { dev : context . dev , serverDistDir : this . serverDistDir } ) ;
170
170
}
You can’t perform that action at this time.
0 commit comments