feat: added spa cache control

This commit is contained in:
=
2025-11-24 22:45:00 +05:30
parent e719de8710
commit 186c08ad27
5 changed files with 26 additions and 10 deletions

View File

@@ -34,6 +34,7 @@ ENV VITE_POSTHOG_API_KEY $POSTHOG_API_KEY
ARG INTERCOM_ID
ENV VITE_INTERCOM_ID $INTERCOM_ID
ARG INFISICAL_PLATFORM_VERSION
ENV INFISICAL_PLATFORM_VERSION $INFISICAL_PLATFORM_VERSION
ENV VITE_INFISICAL_PLATFORM_VERSION $INFISICAL_PLATFORM_VERSION
ARG CAPTCHA_SITE_KEY
ENV VITE_CAPTCHA_SITE_KEY $CAPTCHA_SITE_KEY

View File

@@ -43,7 +43,9 @@ export const registerServeUI = async (
const frontendPath = path.join(dir, frontendName);
await server.register(staticServe, {
root: frontendPath,
wildcard: false
wildcard: false,
maxAge: "30d",
immutable: true
});
server.route({
@@ -58,11 +60,12 @@ export const registerServeUI = async (
return;
}
// This should help avoid caching any chunks (temp fix)
void reply.header("Cache-Control", "no-cache, no-store, must-revalidate, private, max-age=0");
void reply.header("Pragma", "no-cache");
void reply.header("Expires", "0");
return reply.sendFile("index.html");
return reply.sendFile("index.html", {
immutable: false,
maxAge: 0,
lastModified: false,
etag: false
});
}
});
}

View File

@@ -1,9 +1,5 @@
@import "tailwindcss";
@import "@fontsource/inter/400.css" layer(base);
@import "@fontsource/inter/500.css" layer(base);
@import "@fontsource/inter/700.css" layer(base);
@source not "../public";
/*

View File

@@ -12,6 +12,8 @@ import { NotFoundPage } from "./pages/public/NotFoundPage/NotFoundPage";
// Import the generated route tree
import { routeTree } from "./routeTree.gen";
import "@fontsource/inter/400.css";
import "@fontsource/inter/500.css";
import "@xyflow/react/dist/style.css";
import "nprogress/nprogress.css";
import "react-toastify/dist/ReactToastify.css";

View File

@@ -23,6 +23,11 @@ const virtualRouteFileChangeReloadPlugin: PluginOption = {
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
const allowedHosts = env.VITE_ALLOWED_HOSTS?.split(",") ?? [];
const version = (
env.INFISICAL_PLATFORM_VERSION ||
env.VITE_INFISICAL_PLATFORM_VERSION ||
"0.0.1"
).replaceAll(".", "-");
return {
server: {
@@ -38,6 +43,15 @@ export default defineConfig(({ mode }) => {
// }
// }
},
build: {
rollupOptions: {
output: {
entryFileNames: `assets/[name]-${version}-[hash].js`,
chunkFileNames: `assets/[name]-${version}-[hash].js`,
assetFileNames: `assets/[name]-${version}-[hash].[ext]`
}
}
},
plugins: [
tsconfigPaths(),
nodePolyfills({