Override default file based cache location #72855
jordan-edrop
started this conversation in
Ideas
Replies: 1 comment
-
This is greatly needed. I wanted to mount a docker volume at a file path to use as the cache. For that to work, all the cache entries need to be in one folder, ideally a configurable one or even simply // cache-handler.mjs
// A Cache Handler that makes NextJS store all cache entries in its own .next/cache folder.
import RawFileSystemCache from "next/dist/server/lib/incremental-cache/file-system-cache.js";
import path from "node:path";
const FileSystemCache =
RawFileSystemCache.default?.default ?? RawFileSystemCache.default;
export default class CacheHandler extends FileSystemCache {
constructor(options) {
if (!options.serverDistDir) {
throw new Error("Expected serverDistDir");
}
super({
...options,
serverDistDir: path.join(options.serverDistDir, "../cache/server"),
});
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
We are self hosting a Docker image that is deployed to multiple clusters, but this results in two independent caches that is difficult to keep in sync.
This is addressed in the docs here
However you have to create a custom cache implementation. The docs are a little disingenuous with the example, and in reality the NextJS cache is full of internal logic that if you don't replicate will miss out on features.
The current workaround is to copy this file, change the file system path to point to the shared storage. However this is just an internal file to NextJS and is frequently updated with no actual documentation, as it is not treated as a public facing API
Proposal
Add the ability via
next.config.js
to specify the path used by the file-system-cacheBeta Was this translation helpful? Give feedback.
All reactions