Skip to content

Modern Docker Management, Designed for Everyone

fix: let the frontend recover from stale chunks after a redeploy

Kyle Mendell8c294a7316f3
diff --git a/backend/frontend/frontend.go b/backend/frontend/frontend.go
index e8763bb84..ae76b1c3f 100644
--- a/backend/frontend/frontend.go
+++ b/backend/frontend/frontend.go
@@ -43,6 +43,9 @@ func RegisterFrontend(e *echo.Echo) error {
}
if _, statErr := fs.Stat(distFS, requestedPath); os.IsNotExist(statErr) {
+ if strings.HasPrefix(requestedPath, "_app/") {
+ return c.NoContent(http.StatusNotFound)
+ }
req.URL.Path = "/"
}
@@ -97,8 +100,8 @@ func (f *FileServerWithCaching) ServeHTTP(w http.ResponseWriter, r *http.Request
return
}
- // Never cache index.html - it needs to be fresh to detect updates
- if path == indexHtmlFileConstant {
+ // Never cache index.html or version.json - they need to be fresh to detect updates
+ if path == indexHtmlFileConstant || path == "_app/version.json" {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Pragma", "no-cache")
w.Header().Set("Expires", "0")
@@ -107,7 +110,7 @@ func (f *FileServerWithCaching) ServeHTTP(w http.ResponseWriter, r *http.Request
}
// For immutable assets (with content hashes), use long-term caching
- if strings.Contains(path, "/_app/immutable/") {
+ if strings.HasPrefix(path, "_app/immutable/") {
w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
http.FileServer(f.root).ServeHTTP(w, r)
return
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index 4816ca8cb..ec4a7814b 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -5,7 +5,6 @@ import { sveltekit } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
import { defineConfig, searchForWorkspaceRoot, lazyPlugins } from 'vite-plus';
import Icons from 'unplugin-icons/vite';
-import packageJson from './package.json' with { type: 'json' };
const devBackendURL = process.env['DEV_BACKEND_URL'] || 'http://localhost:3552';
const parsedDevBackendURL = new URL(devBackendURL);
@@ -49,11 +48,7 @@ export default defineConfig(({ command }) => ({
adapter: adapter({
pages: process.env['BUILD_PATH'] ?? '../backend/frontend/dist',
fallback: 'index.html'
- }),
- version: {
- name: packageJson.version,
- pollInterval: 0
- }
+ })
}),
paraglideVitePlugin({
project: './project.inlang',