Skip to content

Instantly share code, notes, and snippets.

@tanandy
Forked from johngrimes/nginx.conf
Created June 11, 2021 16:34
Show Gist options
  • Save tanandy/55db4430df686de1de2e7beb95e85cc2 to your computer and use it in GitHub Desktop.
Save tanandy/55db4430df686de1de2e7beb95e85cc2 to your computer and use it in GitHub Desktop.
Ideal Nginx configuration for JavaScript single-page app
server {
listen 80;
root /usr/share/nginx/html;
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
gzip_comp_level 9;
etag on;
location / {
try_files $uri $uri/ /index.html;
}
location /static/ {
add_header Cache-Control max-age=31536000;
}
location /index.html {
add_header Cache-Control no-cache;
}
location /config.json {
add_header Cache-Control no-cache;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment