diff --git a/docker/nginx.conf b/docker/nginx.conf index 8e6f57d..5fba4e5 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -11,23 +11,26 @@ server { gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml; gzip_comp_level 6; + location = /index.html { + add_header Cache-Control "no-cache, no-store, must-revalidate"; + add_header Pragma "no-cache"; + add_header Expires "0"; + } + location /health { access_log off; return 200 'OK'; add_header Content-Type text/plain; } - location / { - 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 /assets/ { + add_header Cache-Control "public, max-age=31536000, immutable"; + try_files $uri =404; + access_log off; } - location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { - expires 1y; - add_header Cache-Control "public, immutable"; - access_log off; + location / { + try_files $uri $uri/ /index.html; } error_page 404 /index.html; diff --git a/src/App.vue b/src/App.vue index e9e9727..5c1dfd4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,9 @@ diff --git a/src/main.ts b/src/main.ts index 23817d1..5c6feae 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,5 +34,15 @@ app.use(language) for (const [key, component] of Object.entries(ElementPlusIconsVue)) { app.component(key, component) } + +window.addEventListener('vite:preloadError', event => { + event.preventDefault() + const key = '__chunk_reload__' + if (!sessionStorage.getItem(key)) { + sessionStorage.setItem(key, '1') + window.location.reload() + } +}) + app.mount('#app')