What is the importance of correct MIME types?

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?

-------------Problems Reply------------

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

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.

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.

Category:html Views:0 Time:2010-01-11
Tags: html mime

Related post

  • Serving your XHTML with the correct MIME type 2011-05-15

    As long as I can remember, I've make a great effort to do things the proper way. Well, what I consider the proper way to be anyway. Now I feel that it is time to get some very important questions answered once and for all. All who swear to XHTML will

  • What is the correct MIME type to use for an RSS feed? 2009-02-27

    Is one MIME type preferable to ensure compatibility with RSS readers and other scrapers? The options seem to be: text/xml text/rss+xml Interestingly Stackoverflow is using text/html. --------------Solutions------------- Neither. It's application/rss+

  • Php doesn't return the correct mime type 2011-03-07

    The finfo function is returning crazy mime types. Look the following code, what the hell is going on ? <?php $files = array ("css.css", "index.html", "js.js", "png.png"); $info = finfo_open (FILEINFO_MIME_TYPE); for ($i = 0; $i < count ($files)

  • What is the correct MIME type for a CSV File created by Excel with semicolon as separator 2011-07-27

    I work in Switzerland, where the semicolon ; is the "official" list separator in Windows' regional settings. Excel uses this separator when creating CSV files. In RFC 4180 the CSV file is defined as comma separated and has the mime type of text/csv a

  • Trouble with getting a CouchApp to output the correct mime type for an appcache 2011-08-22

    So in CouchDB, you can supposedly change mime types. In Futon you just have to go and edit the source of the document and change the content_type field on attachments in the _attachment field. Trouble is, when I do this so that an appcache file has t

  • Apache not assigning correct MIME type for .manifest HTML5 offline file 2011-12-12

    I'm running XAMPP apache web server and developing an HTML5 project and the .manifest file is not being 'assigned' the correct MIME type by the web server. If a user accesses my HTML5 web app and tries to use it offline it will fail because my web se

  • PHP - Opening uploaded DOCX files with the correct MIME TYPE 2010-02-17

    I have users uploading DOCX files which I make available for download. The issues we have been experiencing is the unknown mime types of DOCX files which causes IE to open these docs as Zip files. It is running on a Windows/IIS server. Because this i

  • What is a correct mime type for docx, pptx etc? 2010-11-18

    For older *.doc documents this was enough: header("Content-Type: application/msword"); What mime type should I use for new docx documents? Also for pptx and xlsx documents? --------------Solutions------------- Here are the correct mimetypes: Extensio

  • Unable to get the correct mime type of .flv file 2010-12-16

    I want to get the mime type of local .flv file by using this function from code project http://www.codeproject.com/KB/dotnet/ContentType.aspx Public Function GetMIMEType(_ ByVal filepath As String) As String Dim regPerm As RegistryPermission = _ New

  • Correct mime type for .mp4 2012-03-29

    I have two applications as mentioned below: Admin application through which I am able to upload a .mp4 file to the server. I am trying to download the .mp4 using mobile application in iPad. The Admin application is made by using asp.net 4.0 and SQL S

  • Reading a file from a UNC path and setting the correct MIME type in a HTTP request 2010-10-14

    How would I go about reading a file from a UNC path, discovering the proper MIME type, and streaming that out to a browser? It feels to me like I'm re-inventing IIS, and I'll also have to maintain my own MIME type database for each file extension. Do

  • How to implement a general Mime type correctly in PHP? 2009-12-26

    If you click view,you'll open that file in browser, I've tried : readfile('test.jpg'); But seems it fails in firefox. --------------Solutions------------- If you want to get the mime-type for a file, you have at least two options, in PHP : The first

  • Correct Apache AddType directives for font MIME types 2011-09-14

    I’m using @font-face for embedded fonts (thanks Paul Irish). In trying to fix Chrome’s warning about wrong MIME type for woff fonts, I’ve discovered a mass of conflicting suggestions. Everyone seems to agree that .eot fonts (for IE 6-8?) should be se

  • Nginx: Correctly setting the mime type for gzipped styles/scripts 2011-12-16

    I have a gzip-compressed style and scripts in files: /scripts.js.gz /styles.css.gz The problem is that it does not serve the correct mime-type and browser does not recognize, that the files are compressed css or js (browser recognize the type as appl

  • Using .NET, how can you find the mime type of a file based on the file signature not the extension 2008-09-12

    I am looking for a simple way to get a mime type where the file extension is incorrect or not given, something similar to this question only in .Net. --------------Solutions------------- In Urlmon.dll, there's a function called FindMimeFromData. From

  • REST - web service response - mime type? 2010-10-24

    1) Is it important to set the correct mime type for a web service response? 2) what is the correct mime type for a, a) XML response? b) JSON response? application/xml text/xml application/json application/x-javascript text/javascript text/x-javascrip

  • How does "Proper MIME type for all files" page loading times or user experience in the browser 2011-05-19

    I see it in performance optimizations plugins for wordpress and even Paul Irish's HTML5 boilerplate in the .htaccess file. I don't get how mine type affects performance. Don't browsers already know how to interpret these files? Why tell them how to d

  • Grails / Chrome Error: resource interpreted as Font but transferred with MIME type application/octet-stream 2013-02-18

    How in Chrome can you set the mime type for a woff font, as used by the font-awesome bootstrap library? --------------Solutions------------- Create a Grails custom mapper by putting the below FontResourceMapper.groovy file into the folder: grails-app

  • Downloading Docx from IE - Setting MIME Types in IIS 2008-10-07

    I am sure there is a simple answer to this one. I have a docx file that I get an error when trying to download(document cannot be found).... .doc is fine .txt is also fine. I am sure this is just an iis setting, the permissions on the server are all

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.061 (s). 11 q(s)