server {
    listen 80 default_server;
    charset utf-8;
    root /usr/share/nginx/html;
    index index.html;

    # 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";
    }

    # When requesting static paths with extension, try them, and return a 404 if not found
    location ~* .+\.(css|js|html|png|jpe?g|gif|bmp|ico|json|csv|otf|eot|svg|svgz|ttf|woff|woff2|ijmap|pdf|tif|map) {
        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;
    }
}