Thursday, July 31, 2008

Configure the Server for MIME Types

After you write the web pages, it is time to publish them online. You can publish through either a web-hosting service or your own server. But before anyone can view your web pages, you must configure the server with the right Multipurpose Internet Mail Extensions (MIME) types.

When the web browser accesses any resource (e.g., a file) on the server, the server first returns the content's MIME type. Then, based on the MIME type, the browser determines how to render the content. For example, the server returns a text/html MIME type for an HTML page so that the browser knows it needs to parse the tags and render the HTML presentation elements. If the server returns the text/plain MIME type for the HTML page, the browser thinks it's plain text, and displays all the characters including the HTML tags. The server returns the image/jpeg MIME type of a JPEG image and the browser renders the binary data stream into an image. For the mobile browser to properly render the contents of your web site, the server must be configured to send the right MIME types. The server typically associates a MIME type for each filename suffix.

Scripts will generally set the correct MIME type using Content-Type header that's sent out in the HTTP response header. So, the filename suffix of a script does not necessarily determine its MIME type. See "Dynamic content," later in this section.



No comments: