Skip to content

Commit

Permalink
fix(web): fix pwa cache (#1905)
Browse files Browse the repository at this point in the history
  • Loading branch information
0fatal committed Mar 14, 2024
1 parent c354d4a commit ab28cd4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM nginx:alpine

COPY ./nginx.conf /etc/nginx/conf.d/default.conf
COPY ./dist /usr/share/nginx/html
COPY ./dist /usr/share/nginx/html
COPY ./mime.types /etc/nginx/mime.types
4 changes: 4 additions & 0 deletions web/mime.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include mime.types;
types {
application/manifest+json webmanifest;
}
19 changes: 18 additions & 1 deletion web/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,27 @@ server {

#access_log /var/log/nginx/host.access.log main;

# all assets contain hash in filename, cache forever
location ^~ /assets/ {
add_header Cache-Control "public, max-age=31536000, s-maxage=31536000, immutable";
try_files $uri =404;
}

# all workbox scripts are compiled with hash in filename, cache forever
location ^~ /workbox- {
add_header Cache-Control "public, max-age=31536000, s-maxage=31536000, immutable";
try_files $uri =404;
}

# assume that everything else is handled by the application router, by injecting the index.html.
location / {
autoindex off;
expires off;
add_header Cache-Control "public, max-age=0, s-maxage=0, must-revalidate" always;

root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
try_files $uri $uri/ /index.html =404;
}

#error_page 404 /404.html;
Expand Down
1 change: 1 addition & 0 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default defineConfig(({ command, mode }) => {
workbox: {
globPatterns: ["**/*.{js,css,html,png,svg,json}"],
navigateFallbackDenylist: [/^\/v1/],
maximumFileSizeToCacheInBytes: 10000000,
},
manifest: {
name: "laf",
Expand Down

0 comments on commit ab28cd4

Please sign in to comment.