Skip to content

Instantly share code, notes, and snippets.

@lindsayevans
Created January 25, 2011 11:16
Show Gist options
  • Save lindsayevans/794800 to your computer and use it in GitHub Desktop.
Save lindsayevans/794800 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>
@obber
Copy link

obber commented Aug 25, 2014

Hey thanks for this! It really helped :)

@tekshrek
Copy link

Hi, great thanks! :-)

@lackneets
Copy link

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

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