From 9e8f073c78dac9864023fd939b50c0c665e9a558 Mon Sep 17 00:00:00 2001 From: Alessandro Vendruscolo Date: Mon, 13 Aug 2012 18:34:19 +0200 Subject: [PATCH] Fix for #85 There were two location blocks for webfonts, so `Access-Control-Allow-Origin` never matched. Cache rules have been replicated in the latter webfont location block. We now have just one location block for webfonts, that contains CORS rules **and** cache rules. --- nginx/sites-available/example.com | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nginx/sites-available/example.com b/nginx/sites-available/example.com index b7fa82f..389c459 100644 --- a/nginx/sites-available/example.com +++ b/nginx/sites-available/example.com @@ -66,8 +66,8 @@ server { add_header Cache-Control "public"; } - # Media: images, video, audio, HTC, WebFonts - location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ { + # Media: images, video, audio, HTC + location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|mp4|ogg|ogv|webm)$ { expires 1M; access_log off; add_header Cache-Control "public"; @@ -89,6 +89,13 @@ server { # Cross domain webfont access location ~* \.(ttf|ttc|otf|eot|woff|font.css)$ { add_header "Access-Control-Allow-Origin" "*"; + + # Also, set cache rules for webfonts. + # Unfortunately we cannot have more than one location block match + # https://github.com/h5bp/server-configs/issues/85 + expires 1M; + access_log off; + add_header Cache-Control "public"; } # Prevent mobile network providers from modifying your site