# Set expires for static files # Note to self (and to anyone forks it) # Some sites create robots.txt and sitemap(.xml(.gz)) files on the fly # If you are sure that they are indeed static, uncomment the following location blocks for each and adject the expires headers to fit your site's needs # location = /robots.txt { expires 1d; log_not_found off; access_log off; } # location ~ \.xml(\.gz)?$ { expires 600s; log_not_found off; access_log off; } # For CSS / JS location ~ \.(?:css|js)$ { expires max; log_not_found off; access_log off; add_header X-Content-Type-Options "nosniff"; } # Web fonts needs some special care # Reference: http://jmoiron.net/blog/serving-fonts-aws-cloudfront/ location ~ \.(?:ttf|ttc|eot|woff|woff2|otf|svg)$ { # Safe to use the following line add_header Access-Control-Allow-Origin "*"; # use the following with caution! # add_header Access-Control-Allow-Origin "http://*.example.com"; expires max; log_not_found off; access_log off; } # Referers for images location ~ \.(?:gif|ico|webp)$ { ### Please change the domainname before uncommenting the following # valid_referers none blocked www.example.com example.com; # if ($invalid_referer) { return 403; } expires max; log_not_found off; access_log off; } location ~* ^.+\.(png|jpe?g)$ { ### Please change the domainname before uncommenting the following # valid_referers none blocked www.example.com example.com; # if ($invalid_referer) { return 403; } # add_header Vary Accept; # see https://docs.ewww.io/article/16-ewww-io-and-webp-images try_files $uri$webp_suffix $uri =404; expires max; log_not_found off; access_log off; } # Feeds location ~ \.(?:rss|atom)$ { expires 600s; # 10 minutes }