MIME stands for Multi-purpose Internet Mail Extensions. Though, the use of the word MIME has evolved to encompass data transactions outside the realm of web mail. Back in the day, MIME types simply defined content delivered between mailing servers and clients (Outlook) for 1-on-1 communication. But now they are used by clients like browsers (Chrome) to interpret global communication.
MIME types are also called media types and content types.
A Simple Explanation of MIME Types
A MIME type consists of two parts. The first part defines what web content is at a high level (image, video, application, etc.); the second part defines what web content is at a more detailed level (png, avi, javascript, etc.). This two-part definition is needed so clients like web browsers can translate content that servers give them into terms users like us can experience. Here are some basic examples of how MIME types are displayed:
image/png
video/avi
application/javascript
Using the last example: The MIME value of application/javascript
is for identifying JavaScript. The “type” is application
and the “subtype” is javascript
. We’ll get into more terminology and details below, but first let’s go over why we’re bringing MIME types up in the first place.
Why We’re Talking About MIME Types
In November 2015, MaxCDN’s Justin Dorfman and his partner Josh Mervine ran into a dilemma when rewriting content-type
tests for BootsrapCDN, an open source CDN powered by MaxCDN that delivers JavaScript, CSS, and Fonts for open source projects. The dilemma came about because there is currently more than one variation of MIME type for JavaScript. And as a CDN trying to stay on top of new best practices, the BootstrapCDN team had to find out what the best practice was for naming JavaScript MIME types. After some research, they found that the standard is registered as application/javascript
by the Internet Engineering Task Force (IETF). Some JavaScript MIME types considered “obsolete” by the IETF include:
text/javascript
text/x-javascript
application/x-javascript
Although the IETF only considers application/javascript
as the standard MIME type for JavaScript, variations do need to be accepted. For instance, Google uses text/javascript
. Regardless, Google web properties still continue to function. So even though using the standard MIME type doesn’t really matter, it does, which is why we’re talking about MIME types.
Source: xkcd
A Technical Explanation of MIME Types
Most operating systems like Microsoft Windows, Mac OS X, or the various Linux distributions identify file types through file name extensions - usually the three characters following the dot ending a file name (example: .doc). Likewise, an operating system associates applications that should read and edit certain file types. For example, in Microsoft Windows we typically would see Microsoft Word opening a file ending with the .doc extension (application/msword
), and an image viewer would open a file with the .jpeg extension (image/jpeg
).
By default, Microsoft Windows hides file name extensions from the user's view for convenience. They can be enabled by following instructions in this how-to by Microsoft.
The equivalence of “filename extensions” on the Internet is provided by MIME types. They tell web browsers and email clients what type of files they are dealing with so the application knows how to process the file. Just the way operating systems associate default programs and actions to file name extensions, applications on the Internet make use of the MIME types. MIME types are defined in two parts, having a “type” and a “sub-type” as described in the first section of this article. If you look at the HTTP header of a PNG image, you’ll see the MIME type defined in the Content-Type
field. Here is the HTTP header of an image file from the MaxCDN Blog:
HTTP/1.1 200 OK
Date: Sun, 10 Jan 2016 12:56:04 GMT
Content-Type: image/png
Content-Length: 2075
The MIME type is image/png
. That tells the browser the resource is of type "image" and sub-type “png”, which we usually refer to as the image format. The browser can then decide on how to display the image, whether it can display or does not have the required technology to display such type of image. This is more common with audio and video types. The ability to categorize resources in types and sub-types gives applications a unique advantage to provision when displaying web content. For example, if a browser receives a file from a web server of type audio/xyz
, it might not have the required plugin to play. But because the browser at least understands it is an audio file, it can prompt the user accordingly. The Content-Type
field may carry additional information called “arguments” and there may be several arguments for the MIME type. One example of an argument is the character-set information for the text/html
type. Here is a part of the HTTP header from the MaxCDN Blog showing the Content-Type
field:
HTTP/1.1 200 OK
Date: Sun, 10 Jan 2016 13:07:47 GMT
Content-Type: text/html; charset=UTF-8
The Content-Type
field accepts several arguments and their order is not important. In the above header extract, the argument is “charset=UTF-8”. The browser thus interprets the resource as text of sub-type html
and the character set required is UTF-8
. There is an official list of MIME Types published by the Internet Assigned Names and Numbers Association (IANA), which is regularly updated. The list contains MIME types that have been reviewed by the association.
Experimental MIME Types
Applications sometimes would denote MIME types that aren't “official,” or experimental, by prefixing the sub-type with “x-”. For example, for some time the JavaScript MIME Type application/x-javascript
was referred to as text/javascript
until RFC 4329 rendered text/javascript
as obsolete (giving it the official status of application/javascript
).
MIME Type Resources
Technical standards by the IETF have lengthily described the MIME format. I recommend that Internet geeks be familiar with the following RFCs:
- RFC 2045 – MIME, Format of Internet Message Bodies
- RFC 2046 – MIME, Media Types
- RFC 2047 – MIME, Message Header Extensions for Non-ASCII Text
- RFC 4289 – MIME, Registration Procedures
- RFC 2049 – MIME, Conformance Criteria and Examples
And here are some MIME types lists:
- MIME Types List (Free for Matter)
- The Complete List of MIME Types (Sitepoint)
As always, If you have any questions or concerns about any of the topics mentioned in this article, please feel free to reach out to support. Live chat and ticket support are available 24/7.