Base cacheHandler for next.js, which cache data in-memory
Using npm:
npm i next-impl-cache-in-memory
Using yarn:
yarn add next-impl-cache-in-memory
You can use cacheHandler by specifying the path to it in the application configuration:
/** @type {import('next').NextConfig} */
const nextConfig = {
cacheMaxMemorySize: 0,
cacheHandler: require.resolve('next-impl-cache-in-memory'),
};
However, it is recommended to use it together with next-impl-cache-adapter. The package will allow you to expand the capabilities of cacheHandler and also reuse the cache between different application instances. More details
Base example with next-impl-cache-in-memory. See example.