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.

NOTE: 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.

a comical sketch on how web standards proliferate
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).

NOTE: 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’s 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:

And here are some MIME types lists:

 

Ish Sookun is a Linux enthusiast and a Free & Open Source Software advocate. He works as a Linux System Administrator at a leading media group in Mauritius where he builds http://www.lexpress.mu/. In his free time, you can find him writing about Linux, Ubuntu, and programming on his blog Hacklog.