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:

  • Use separate cache files
    - this option will create separate cache file per device. For example: pageIpad, pageIphone, pageWindowsMobile etc. If you set this option to no, then a single cache group pageMobile is created for all mobile devices.
  • iphone, ipad, android, operaMini, blackberry, palm, windowsMobile browser
    - with this options you set the way the plugin is going to treat those mobile browsers. If it is true the plugin is going to treat them as real mobile browser, if it is false they are going to be treated as desktop browsers and will not get their own cache group.
  • Use browser caching and cache lifetime
    - those options do the same as the options in the default joomla system plugin.
  • Disable on debug
    - this option is handy if you want to measure the performance with cache on and off on your website. If you have set System debug to true in Global config then you will get information such as - how fast the page was created and how many MB of ram were used.

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

Rate this blog entry:
Hack CompojoomComment and win a prize!
Publish/Unpublish from frontend