谷歌警告:资源解释为字体,但与MIMEtypes的应用程序/八位字节stream转移

我在Google中对我的字体有一个警告:

Resource解释为Font,但是使用MIMEtypesapplication / octet-stream传输:“… / Content / Fonts / iconFont.ttf”。

它即使我有这个警告,但我宁愿避免这个警告。

这里是我的报关表:

@font-face { font-family: 'iconFont'; src: url('../Fonts/iconFont.eot?#iefix') format('embedded-opentype'), url('../Fonts/iconFont.svg#iconFont') format('image/svg+xml'), url('../Fonts/iconFont.woff') format('font/x-woff'), url('../Fonts/iconFont.ttf') format('truetype'); font-weight: normal; font-style: normal; } 

我已经在其他post上search,但到目前为止没有运气。

请注意,我的服务器是来自Microsoft的IIS。

任何想法我怎么能避免这个警告?

谢谢。

另一种方法在这里:http: //zduck.com/2013/google-chrome-and-woff-font-mime-type-warnings/

在web.config中使用下面的设置:

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

您需要将下列types添加到.htaccess / IIS:

 AddType application/vnd.ms-fontobject .eot AddType font/ttf .ttf AddType font/otf .otf AddType application/font-woff .woff 

更新.wofftypes来自:

 AddType application/x-font-woff .woff 

(感谢@renadeen在下面的评论中指出了这一点。)

看看我的答案在这里类似的问题: 字体面没有加载

从这里采取: 在铬中的字体 – 面对问题 。

感谢上面的答案@ 97ldave,你可以添加这些types到你的IIS web服务器configuration部分,如果你不想把它们直接添加到你的IIS设置中的MIMEtypes。 以下显示了仅添加configuration中缺less的.wofftypes的示例。 这解决了在我的iMac上没有出现在最新版本的Safari(6.0.3)中的字体的问题。

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

感谢Jon Samwell(我的同事)发现这一点。

对于Nginx:(path:/etc/nginx/mime.types)

 font/ttf ttf; font/otf otf; application/x-font-woff woff; 

你不需要application/vnd.ms-fontobject eot; 因为它已经存在了。

之后,重新启动Nginx: service nginx restart

完成。

正确的MIMEtypes的字体是:

 application/font-ttf ttf; application/font-otf otf; application/font-woff woff; 

如果你用nodeJS运行一个服务器,这是一个很好的模块来映射你的MIMEtypes

https://github.com/broofa/node-mime

 var mime = require('mime'); mime.lookup('/path/to/file.txt'); // => 'text/plain' mime.lookup('file.txt'); // => 'text/plain' mime.lookup('.TXT'); // => 'text/plain' mime.lookup('htm'); // => 'text/html' mime.extension('text/html'); // => 'html' mime.extension('application/octet-stream'); // => 'bin' 

感谢@参议员和@ 97ldave的答案

对于我来说,在将这些行添加到web.config后,错误完全消失

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