Skip to content

Instantly share code, notes, and snippets.

@lgraubner
Created August 3, 2016 10:49
Show Gist options
  • Select an option

  • Save lgraubner/2cb981fd807c719b7bf2ffac819c90b3 to your computer and use it in GitHub Desktop.

Select an option

Save lgraubner/2cb981fd807c719b7bf2ffac819c90b3 to your computer and use it in GitHub Desktop.

Revisions

  1. lgraubner created this gist Aug 3, 2016.
    39 changes: 39 additions & 0 deletions expires.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    # Expire rules for static content

    # No default expire rule. This config mirrors that of apache as outlined in the
    # html5-boilerplate .htaccess file. However, nginx applies rules by location,
    # the apache rules are defined by type. A consequence of this difference is that
    # if you use no file extension in the url and serve html, with apache you get an
    # expire time of 0s, with nginx you'd get an expire header of one month in the
    # future (if the default expire rule is 1 month). Therefore, do not use a
    # default expire rule with nginx unless your site is completely static

    # cache.appcache, your document html and data
    location ~* \.(?:manifest|appcache|html?|xml|json)$ {
    expires -1;
    }

    # Feed
    location ~* \.(?:rss|atom)$ {
    expires 1h;
    }

    # Media: images, icons, video, audio, HTC
    location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
    expires 1M;
    access_log off;
    add_header Cache-Control "public";
    }

    # CSS and Javascript
    location ~* \.(?:css|js)$ {
    expires 1d;
    access_log off;
    }

    # WebFonts
    # If you are NOT using cross-domain-fonts.conf, uncomment the following directive
    location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
    expires 1M;
    access_log off;
    }