Mobile templates and the joomla cache

We were working for a customer that has a highly visited website (50 000+ users/day). As you can imagine the joomla cache is your friend in such situations. However if you are using a template that generates a different view for users coming from a mobile device, then your worst dream may come true :). We were faced with a situation where a desktop user gets the mobile version of the page and the mobile user gets the desktop version. Why does this happen?

When you request an url, the joomla cache plugin checks if a cached version of this single page exists. If it is not existing, then it creates it. In this process it doesn't check the device that is requesting the page. Since our template generates a mobile view for our mobile users, the joomla cache plugin stores this mobile version in the cache file. So we end up with a situation where user A browsing with an iphone creates a cache file and this cache file is served to all users visiting the same page...

We solved this problem by writting a new cache plugin that takes in account the user's device and creates separate cache files for an iphone, windowsMobile and other devices. In the next screenshot you can see all of the existing options:

Options explained:

You can get the plugin in the download area of the site against a small subscription fee of 5€.

P.S. If you want to learn more about the caching mechanism of joomla you can read this wonderfull article from Andrew Eddie: Joomla Caching Explained