Chapter 17. Content Delivery

Content delivery is a common need in the mobile web world. Applications, music, video, wallpapers, and any other content can be delivered to compatible devices, but this requires a bit of explanation and expertise.

Note

We covered video delivery to mobile devices in Chapter 10.

MIME Types

MIME types, many of which are listed in Appendix A, are a key element for content delivery. Mobile browsers don’t care about the file extension; they decide whether or not to accept the content based on the MIME type delivered by the server. Remember that the MIME type travels with the HTTP header response.

Static Definition

The simplest way to define the right MIME types is to statically define them on your web server. If you are working with a shared hosting service, the control panels often allow you to define document MIME types. If you manage your own server, you can set them up with the following instructions.

Apache

In Apache, the simplest way is to open the mime.types file located in the conf folder of the Apache root. In your favorite text editor, you can add one row per MIME type to be configured.

You will find hundreds of MIME type declarations. The first thing to do is to look for the following line and change the MIME type to the correct one for mobile XHTML documents:

text/html                    html htm

As you can see, each line contains a MIME type followed by a series of spaces or tabs and a space-separated list of file extensions.

Warning

This technique applies these changes to ...

Get Programming the Mobile Web, 2nd Edition 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.