Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woff file mime type and Azure

I am trying to deploy an ASP.Net MVC4 TwitterBootstrap application to my new hosting at Azure.

All is working 100%, except, a file '\Fonts\glyphicons-halflings-regular.woff' was throwing a 404 error when using Chrome (The network tab when using F12).

I checked my solution, and the file IS there:

enter image description here

I googled away, and found that it was a mime type issue and Azure. I found a link that said that the fix was to add this to web.config.

<staticContent>
  <mimeMap fileExtension="woff" mimeType="application/font-woff" />
</staticContent>

I did that, and the 404 no longer displays. HOWEVER, my page takes an extra 1.56ms to load, because it seems it downloads that woff file every time I load the page - where all other static content seems to be cached on the server on each load.

enter image description here

That was loading the homepage - and is the only file that gets loaded. The rest seems cached?

Loading another page, where other items are loaded, shows that this is the file that the cache doesn't seem interested in:

enter image description here

Is there a way to get this file cached? I think maybe a mime type needs to be added to their server somewhere? I'm kind of new to caching and mime, and Azure. Hopefully there is a solution, as this file is nearly doubling my page load times on all pages on Azure. My other Cheap host did not have this issue.

like image 366
Craig Avatar asked Jul 25 '14 23:07

Craig


2 Answers

Maybe try this... 2 things of note

1) the remove line

2) x-font-woff vs font-woff

<staticContent> <remove fileExtension=".woff" /> <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" /> </staticContent>

Found at http://ideasof.andersaberg.com/development/quick-fix-iis-woff-font-file-404-not-found-in-aspnet-mvc/

like image 64
Craig London Avatar answered Sep 17 '22 08:09

Craig London


Extending Craig's answer for latest bootstrap that includes WOFF2 files. You can also add in

<system.webServer>
    <staticContent>

        <remove fileExtension=".woff2" />
        <mimeMap fileExtension=".woff2" mimeType="font/woff2" />

    </staticContent>
</system.webServer>

(See Proper MIME type for .woff2 fonts for a discussion on current mime type for WOFF2 files)

like image 20
Paul Bullivant Avatar answered Sep 20 '22 08:09

Paul Bullivant