Files
movie-advisor/next.config.js
T
ubuntuandClaude Opus 5.5 c2947bed32 perf(cache): size-capped SQLite cache handler instead of per-file ISR cache
The default Next.js cache writes one file per rendered page and per fetch
and never evicts. With on-demand movie/person/tv pages and crawlers walking
the sitemap, it grew to ~3.7M files (~80 GB) in 5 days, and deleting them
loaded the whole server.

cache-handler.js keeps the ISR and fetch cache in a single SQLite file
(node:sqlite, no native dependency) and evicts the least recently used
entries once it passes NEXT_CACHE_MAX_MB (default 5 GB), so the cache stays
bounded with no cleanup job. The file lives in the container, so each deploy
starts with a fresh cache that never serves pages from an older build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 07:00:35 +00:00

30 lines
642 B
JavaScript

/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
// ISR/fetch cache in one size-capped SQLite file instead of millions of files, see cache-handler.js
cacheHandler: require.resolve('./cache-handler.js'),
cacheMaxMemorySize: 0,
experimental: {
optimizeCss: true,
staleTimes: {
dynamic: 3600,
static: 3600
}
},
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**'
}
]
}
};
const withPWA = require('next-pwa')({
dest: 'public',
disable: process.env.NODE_ENV === 'development'
});
module.exports = withPWA(nextConfig);