Using @neshca/cache-handler
in development environment
Since the primary purpose of @neshca/cache-handler
is to accommodate the sharing of the cache between multiple and independent replicas of the Next.js application, there is no need to use it in a development environment.
The easiest way to turn off the cache handler in a development environment is to use process.env.NODE_ENV
:
next.config.js
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
/* experimental: {
incrementalCacheHandlerPath:
process.env.NODE_ENV === 'production' ? require.resolve('./cache-handler.mjs') : undefined,
}, */
};