For the More Curious: MIME Types
Have you ever wondered how a computer knows how to open a movie
file with a video player and a PDF with a document viewer?
Your computer keeps a table of file types and the programs
associated with those file types. It infers
a file’s type by looking at the file extension (e.g., .html
or .pdf
).
A browser needs those same associations so that it knows whether to render the response as HTML, use a plug-in to play music, or download a file to the hard drive. But HTTP responses do not have file extensions. Instead, the server must tell the browser what type of information is in the response.
It does this by specifying the MIME type or media type
in the response’s Content-Type
header. For example, Figure 15.15 ...
Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.