tags:

views:

423

answers:

3

In my Chrome I am getting these warnings:

Resource interpreted as stylesheet but transferred with MIME type text/plain.
Resource interpreted as script but transferred with MIME type text/html.
pngResource interpreted as image but transferred with MIME type text/plain.

Why should I care? Or what is the probability that there is a browser that wouldn't treat the resource as the main browsers do?

A: 

MIME types let the browser know what each file is. Browsers associate other applications, helper applications/extensions to handle certain MIME types. So, setting the correct MIME types will let the browser handle the object/file the way it was meant to be done.

Alan Haggai Alavi
+3  A: 

The MIME tells the browser what type of content is being delivered. If it is a script, you should let the browser know that it is a script, to make sure it'll always be executed right, for just about the same reason that you should use correct file extensions for the files on your file system.

Here, Chrome is guessing from context that the content delivered is in fact a script, and not, as alleged, html, and perhaps it treats it as a script as well, but this is arguably a bad thing, as you always want to be in control of what you're sending to the browser, and how it interprets that.

Other browser may not be able to execute your script, or display your images, if you don't let them know that they are scripts and images, respectively.

David Hedlund
+4  A: 

Serving files with an incorrect mime type can open up security holes. Here's a high profile example.

Tobu