From 6f5d4ab7f9a374f9e54659ec0aca4650a2fe9985 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 16 Jul 2024 07:54:38 +0000 Subject: [PATCH] fix cache expires issue --- nginx-frontend.conf | 9 +++++++++ vite.config.js | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/nginx-frontend.conf b/nginx-frontend.conf index 1964ef1..28b25fb 100644 --- a/nginx-frontend.conf +++ b/nginx-frontend.conf @@ -19,6 +19,15 @@ http { index index.html; include /etc/nginx/mime.types; try_files $uri $uri/ /index.html; + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires "0"; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + root /usr/share/nginx/html; + expires 1h; + add_header Cache-Control "public"; } } } diff --git a/vite.config.js b/vite.config.js index 58ff10a..2820635 100644 --- a/vite.config.js +++ b/vite.config.js @@ -21,7 +21,6 @@ export default defineConfig(({ mode }) => { Vue({ template: { transformAssetUrls } }), - // https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin#readme Vuetify(), Components(), ViteFonts({ @@ -57,6 +56,16 @@ export default defineConfig(({ mode }) => { '.vue', ], }, + build: { + outDir: 'dist', + rollupOptions: { + output: { + entryFileNames: 'assets/[name].[hash].js', + chunkFileNames: 'assets/[name].[hash].js', + assetFileNames: 'assets/[name].[hash].[ext]' + } + } + }, server: { port: 3000, },