Chapter 10. Server-Side Browser Detection and Content Delivery

Until now, this book has only discussed the client side of mobile web development. Server-side development has an especially important part to play here, though, not only because of all we know about dynamic content generation, but because the server is the only place where we can easily make decisions about what content to send to which devices.

In this chapter we will look at device detection and content delivery, and introduce the creation of a content store. The server also manages the MIME types of content, a very important feature we need to define for good compatibility in the mobile world.


We can use any server-side platform, server, and/or programming language. For the purposes of clarity our samples will use PHP, although this chapter will provide short tips for ASP.NET and Java as well. You can easily export these techniques to any other server platform.

Mobile Detection

Before talking about detection of mobile devices and services on the server, we need to go back a bit and consider an old friend: the HyperText Transfer Protocol, also known as HTTP. Knowing a bit about its internals will help us determine what we can do in terms of mobile web development.


There are no special server requirements for mobile websites; you can just use the same Apache, Internet Information Server (IIS), or other server you are currently using for desktop websites.


HTTP is a protocol originally defined in 1991 for document ...

Get Programming the Mobile Web 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.