1

What's the correct MIME-Type for .css.br files? For ".css" it's "text/css" and for ".js.br" it's "application/x-br" (at least it's working for me). But what to use for ".css.br"?

1 Answer 1

4

I'm not sure the question makes sense and I am not sure what you mean when you say "at least it's working for me"?

The mime-type indicates the file type. If the file ends in .br then the file type is a brotli file - no matter whether it's a brotli compressed css or a brotli compressed js file.

It doesn't look like there is an officially registered brotli mime-type, though a quick Google shows "application/x-br" has been suggested as has application/brotli.

If you are pre-compressing files and want to send them from a web server to the client, then you should send them as .css files (not .css.br) and set the appropriate HTTP Headers:

content-encoding:br
content-type:text/css; charset=utf-8

And similarly for JavaScript files.

Precompression is just a way of saving your web server the trouble of compressing on the fly, but whether it's a precompressed file, or an on-fly compressed file shouldn't result in a difference to what is delivered to the browser.

2
  • Hi Barry, I had to register "br" files with "application/x-br" so IIS is able to serve them (IIS does not serve content with unknown MIME-Type). My current problem is, that the "css.br" files are served but "misinterpreted" by the browser. I tried it with a MIME-Type of "application/x-br" (then they get decompressed but not used correctly - no CSS formatting applied) and when I user "text/css" they don't get decompressed at all (err:....).
    – Alex
    Feb 22, 2018 at 3:24
  • You register the original mime-types (e.g. text/css), rewrite the URLs to strip out the .br part, add a content-encoding response header and turn off dynamic compression. See this post for some details: answers.unity.com/questions/847635/…. So as I said your question as it was stated did not make sense as there is no .css.br mime-type. I’m amazed your solution worked for .js.br files. Feb 22, 2018 at 4:37

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.