Skip to content

Instantly share code, notes, and snippets.

@JPKCom
Forked from lindsayevans/.htaccess
Created April 27, 2016 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JPKCom/9c75fdfbfda1870412ad052accc36461 to your computer and use it in GitHub Desktop.
Save JPKCom/9c75fdfbfda1870412ad052accc36461 to your computer and use it in GitHub Desktop.
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType font/x-woff .woff
AddType image/svg+xml .svg
# Compress compressible fonts
AddOutputFilterByType DEFLATE font/ttf font/otf image/svg+xml
# Add a far future Expires header for fonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType font/otf "access plus 1 year"
ExpiresByType font/x-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
# Add correct content-type for fonts
types {
application/vnd.ms-fontobject eot;
font/ttf ttf;
font/otf otf;
font/x-woff woff;
image/svg+xml svg;
}
# Compress compressible fonts
gzip on;
gzip_comp_level 9;
gzip_types font/ttf font/otf image/svg+xml;
# Add a far future Expires header for fonts
if ($request_uri ~* "\.(eot|ttf|otf|woff|svg)$") {
expires max;
}
<system.webServer>
<!-- Add correct content-type for fonts -->
<staticContent>
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".ttf" mimeType="font/ttf" />
<mimeMap fileExtension=".otf" mimeType="font/otf" />
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
<!-- Compress compressible fonts -->
<httpCompression>
<scheme name="deflate" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
<add mimeType="font/ttf" enabled="true" />
<add mimeType="font/otf" enabled="true" />
<add mimeType="image/svg+xml" enabled="true" />
</staticTypes>
</httpCompression>
<!-- Add a far future Expires header for fonts -->
<!-- (There doesn't appear to be a way to do this for individual types, or to set based on access time, so we're setting it to 1 year in the future for all static content) -->
<staticContent>
<clientCache httpExpires="Mon, 24 Jan 2012 00:00:00 GMT" cacheControlMode="UseExpires" />
</staticContent>
</system.webServer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment