Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# 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
location ~* \.(eot|ttf|otf|woff|svg)$ {
expires @1y;
}
<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>
@obber
Copy link

obber commented Aug 25, 2014

Hey thanks for this! It really helped :)

@tekshrek
Copy link

tekshrek commented Mar 27, 2015

Hi, great thanks! :-)

@lackneets
Copy link

lackneets commented Oct 23, 2015

AddOutputFilterByType DEFLATE font/ttf font/otf image/svg+xml

This increased total transfer data in my case, js, css... are ignored to compress

@ZdrowyGosciu
Copy link

ZdrowyGosciu commented Mar 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment