Web Fonts (.woff specifically) throwing 404s on IIS7

(A message for my future self follows)

EDIT: Future Ross you’re an idiot. Adding it manually simply adds the staticContent entries, the difference was that “application/x-woff” works, and “application/x-font-woff” does not.

Future Ross, you can stop reading now.

Hi Future Ross! If you’re reading this, then odds are that you’ve just deployed another site to IIS and noticed that all the .woff fonts are failing to load with a 404 not found even though they exist on the file system!

You’ve probably Googled or Binged (Bung?) for solutions, and noticed that a lot of them suggest editing the web.config to add entities for .woff and .svg files in the <staticContent> section, and right now you’re wondering why the web.config files for other sites you’ve worked on that use .woff files don’t have that entry in the web.config – right?

Editing the web.config sounds like a good idea, and the suggested entries look reasonable:

<system.webServer>
  <staticContent>
    <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
  </staticContent>   
</system.webServer>

So, Future Ross, why don’t you have them in any of the many web.config files that live in the various source control repositories that you frequent?

As your past self, I can tell you that adding these entries doesn’t seem to work reliably, and can cause random issues in serving up other resources (such as static PNG files), so you discarded it pretty quickly. Instead you’ve used the method of editing the MIME types for the specific site (although adding them to the base list of MIME types for the server would probably be preferable) and adding an entry for .woff as “application/x-woff”, which seems to work well.

In the past, you’ve thought about spending some time working out why a solution which other people swear by seems to not work for you, however by this point you’ve usually just been to happy to have resolved it – as your past self, I’m going to go out on a limb and assume that’ll be the case again this time.

Hope this helps you Future Ross, as well as anyone else who may be reading this!

Tags: , , ,

Posted on Monday, December 16, 2013 12:55 PM |

Like this? Share it!

  • # re: Web Fonts (.woff specifically) throwing 404s on IIS7
    Gravatar
    Commented on 11/11/2014 11:35 AM

    Here's an example staticContent with correct mimetypes, updated for 2014:

    <staticContent>
    <remove fileExtension=".js" />
    <mimeMap fileExtension=".js" mimeType="text/javascript" />
    <remove fileExtension=".svg" />
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
    <remove fileExtension=".woff" />
    <mimeMap fileExtension=".woff" mimeType="application/x-woff" />
    <remove fileExtension=".ttf" />
    <mimeMap fileExtension=".ttf" mimeType="application/octet-stream" />
    <remove fileExtension=".otf" />
    <mimeMap fileExtension=".otf" mimeType="font/opentype" />
    <remove fileExtension=".eot" />
    <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
    <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
    </staticContent>

Post a comment
Please add 3 and 3 and type the answer here:
Remember me?
Ensure the word in this box says 'orange':