From bdb36d6be4dd9c344a7d6a8dcb7124b427db5fd2 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jun 2025 02:59:31 -0400 Subject: [PATCH] disable caching for frontend assets This aims to fix the issue where it says ``` TypeError Cannot read properties of undefined (reading 'component') ``` by telling the browser to not cache any chunks --- backend/src/server/plugins/serve-ui.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/src/server/plugins/serve-ui.ts b/backend/src/server/plugins/serve-ui.ts index 22c097726..fc6b85d3d 100644 --- a/backend/src/server/plugins/serve-ui.ts +++ b/backend/src/server/plugins/serve-ui.ts @@ -57,9 +57,12 @@ export const registerServeUI = async ( reply.callNotFound(); return; } - // reference: https://github.com/fastify/fastify-static?tab=readme-ov-file#managing-cache-control-headers - // to avoid ui bundle skew on new deployment - return reply.sendFile("index.html", { maxAge: 0, immutable: false }); + + // This should help avoid caching any chunks (temp) + reply.header('Cache-Control', 'no-cache, no-store, must-revalidate'); + reply.header('Pragma', 'no-cache'); + return reply.sendFile("index.html"); + } }); }