Sprockets produces wrong content-type for .woff fonts #366

johan opened this Issue Sep 27, 2012 · 5 comments


None yet

4 participants

johan commented Sep 27, 2012

This might be a documentation issue rather than Sprockets' fault per se, but I can't for the life of me figure out how to make Sprockets produce the content-type application/x-font-woff for *.woff files (I saw #296 but didn't manage to repurpose it to a solution), short of patching the actual header assignment in Sprockets::Server::headers, which is surely the wrong way.

Sprockets 2.1.2, which I use with webrick in my local rails 3.2 dev box, produces application/octet-stream, which Chrome Stable (21) wails about in its error console for every web font (*.woff) file loaded with that content-type on every page, which gets old fast:

Resource interpreted as Font but transferred with MIME type application/octet-stream: ...

Things I've tried without much success in the rails app's config/initializers/mime_types.rb (listed here mostly for google benefit to other stranded future developers also seeking solutions in all the wrong places):

Mime::Type.register "application/x-font-woff", :woff, [], %w(.woff)
Rack::Mime::MIME_TYPES['.woff'] = 'application/x-font-woff'
WEBrick::HTTPUtils::DefaultMimeTypes['woff'] = 'application/x-font-woff'
johan commented Sep 27, 2012

For what it's worth, I tried patching my Rack too but didn't have much luck (possibly some late-night oversight of mine, I suppose).

If this is a docs issue, I'd guessing I'm not the first to stumble on it. :-)

johan commented Oct 2, 2012

Ah, the interim kludge is to add this to config/initializers/mime_types.rb:

# tell Rack (and Sprockets) about modern font MIME types:
Rack::Mime::MIME_TYPES['.woff'] = 'application/x-font-woff'

and wipe tmp/cache and restart your server for it to take effect.

Is this entirely Rack's bug, or is the over-caching part a Sprockets issue?


Thanks @johan; Chrome whining silenced.

josh commented Feb 7, 2013

rack issue.

@josh josh closed this Feb 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment