2019-09-22 12:55:21 +03:00
|
|
|
server {
|
|
|
|
listen 80 default_server;
|
|
|
|
charset utf-8;
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
index index.html;
|
|
|
|
|
2020-10-31 15:36:53 +03:00
|
|
|
# Expire rules for static content
|
|
|
|
# HTML files should never be cached. There's only one here, which is the entry point (index.html)
|
|
|
|
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
|
|
|
|
expires -1;
|
|
|
|
}
|
|
|
|
# Images and other binary assets can be saved for a month
|
|
|
|
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
|
|
|
|
expires 1M;
|
|
|
|
add_header Cache-Control "public";
|
|
|
|
}
|
|
|
|
# JS and CSS files can be saved for a year, as they are always hashed. New versions will include a new hash anyway, forcing the download
|
|
|
|
location ~* \.(?:css|js)$ {
|
|
|
|
expires 1y;
|
|
|
|
add_header Cache-Control "public";
|
|
|
|
}
|
|
|
|
|
2019-09-22 12:55:21 +03:00
|
|
|
# When requesting static paths with extension, try them, and return a 404 if not found
|
2020-01-31 03:36:17 +03:00
|
|
|
location ~* .+\.(css|js|html|png|jpe?g|gif|bmp|ico|json|csv|otf|eot|svg|svgz|ttf|woff|woff2|ijmap|pdf|tif|map) {
|
2019-09-22 12:55:21 +03:00
|
|
|
try_files $uri $uri/ =404;
|
|
|
|
}
|
|
|
|
# When requesting a path without extension, try it, and return the index if not found
|
|
|
|
# This allows HTML5 history paths to be handled by the client application
|
|
|
|
location / {
|
|
|
|
try_files $uri $uri/ /index.html$is_args$args;
|
|
|
|
}
|
|
|
|
}
|