Skip to content

Commit

Permalink
Merge pull request #3027 from LiteFarmOrg/LF-3921a-update-nginx-confi…
Browse files Browse the repository at this point in the history
…guration-to-match-vite-pwa-recommendations

LF-3921a Update Nginx configuration to match vite-pwa recommendations
  • Loading branch information
kathyavini authored Dec 6, 2023
2 parents 09b2495 + 89ab67d commit 51e1528
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions packages/webapp/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ http {
client_max_body_size 20M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Add MIME type for manifest.webmanifest
# See https://vite-pwa-org.netlify.app/deployment/nginx.html
types {
application/manifest+json webmanifest;
}
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
Expand All @@ -41,13 +46,37 @@ http {
server {
server_name beta.litefarm.org;

# Set Cache-Control for various pwa-critical routes
# See https://vite-pwa-org.netlify.app/deployment/nginx.html#cache-control
location = /index.html {
root /var/www/litefarm;
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
add_header Cache-Control "public, max-age=0, must-revalidate" always;
}

location / {
location = /manifest.webmanifest {
root /var/www/litefarm;
add_header Cache-Control "public, max-age=0, must-revalidate" always;
}

location = /sw.js {
root /var/www/litefarm;
add_header Cache-Control "public, max-age=0, must-revalidate" always;
}

location ^~ /assets/ {
root /var/www/litefarm;
add_header Cache-Control "public, max-age=31536000, s-maxage=31536000, immutable";
}

location ^~ /workbox- {
root /var/www/litefarm;
add_header Cache-Control "public, max-age=31536000, s-maxage=31536000, immutable";
}

location / {
autoindex off;
expires off;
add_header Cache-Control "public, max-age=0, s-maxage=0, must-revalidate" always;
try_files $uri /index.html;
}
listen 443 ssl; # managed by Certbot
Expand Down

0 comments on commit 51e1528

Please sign in to comment.