👌 IMPROVE: caching

This commit is contained in:
kumarabhirup 2026-03-18 17:23:49 -07:00
parent f29bd0c5c1
commit 7fe870fec0
No known key found for this signature in database
GPG Key ID: DB7CA2289CAB0167
2 changed files with 26 additions and 6 deletions

View File

@ -15,12 +15,29 @@ try {
openclawVersion = oclPkg.version ?? "";
} catch { /* openclaw not resolvable at build time */ }
const denchVersion = rootPkg.version ?? "";
const nextConfig: NextConfig = {
env: {
NEXT_PUBLIC_DENCHCLAW_VERSION: rootPkg.version ?? "",
NEXT_PUBLIC_DENCHCLAW_VERSION: denchVersion,
NEXT_PUBLIC_OPENCLAW_VERSION: openclawVersion,
},
async headers() {
return [
{
source: "/((?!_next/static|_next/image|favicon\\.ico).*)",
headers: [
{
key: "Cache-Control",
value: "private, no-cache, no-store, max-age=0, must-revalidate",
},
{ key: "X-Denchclaw-Version", value: denchVersion },
],
},
];
},
// Produce a self-contained standalone build so npm global installs
// can run the web app with `node server.js` — no npm install or
// next build required at runtime.

View File

@ -694,10 +694,13 @@ function ensureSeedAssets(runtimeAppDir: string, packageRoot: string): void {
}
/**
* Copy .next/static/ and public/ into the runtime app dir if they aren't
* already present. In production the prepack script copies these into the
* standalone app dir before publish, so cpSync already picks them up.
* In dev the prepack hasn't run, so we pull them from the source tree.
* Copy .next/static/ and public/ into the runtime app dir. Always
* force-overwrites so stale assets left by a partial prior install or an
* npx cache hit are replaced with the current build.
*
* In production the prepack script already embeds these in the standalone
* app dir, so cpSync picks them up first; this pass guarantees they match
* the source tree even when the standalone copy is incomplete.
*/
function ensureStaticAssets(runtimeAppDir: string, packageRoot: string): void {
const pairs: Array<[src: string, dst: string]> = [
@ -711,7 +714,7 @@ function ensureStaticAssets(runtimeAppDir: string, packageRoot: string): void {
],
];
for (const [src, dst] of pairs) {
if (existsSync(dst) || !existsSync(src)) continue;
if (!existsSync(src)) continue;
try {
mkdirSync(path.dirname(dst), { recursive: true });
cpSync(src, dst, { recursive: true, dereference: true, force: true });