Proposal: Server Side Responsive, Caching, User Agent Detection (in the core) (1 post)

  1. Stefano Lissa
    Posted 2 years ago #


    I'm playing with responsive blogs those days and even if media queries and javascript can resolve most of the problems, sometimes a server side action can improve the performances of the site sending back only what a phone need (and not everything then partially hidden with media queries).

    To do that a "phone" detection must be in place. I don't use the word "mobile", since the tablets are considered mobile but most of the times a tablet is like a desktop and does not need too much changes on served pages.

    Where the problems lie? Different systems (plugins, caching, themes) have different method to detect a "phone" and they must be kept aligned.

    Specially caches (I'm the author of Hyper Cache and Lite Cache) must be able to separate the pages for phones and desktops (when different) and so should be able to distinguish the UA in the same way as the theme or installed plugins.

    My proposal (it's an example not a specification!): WordPress should have a function is_phone() declared BEFORE the cache activation (when the advanced-cache.php file is loaded). By default this function can be not implemented and return always false.

    Then it should allow a drop-in plugins that override the function with specific user agent detection, for example with a wp-content/advanced-detection.php file.

    Being a core function, every piece of code can use it, even the advanced-cache.php which starts BEFORE plugins are loaded (this is way caches cannot really benefit of plugins which do the user agent detection).

    Instead of the is_phone() function, an wp_get_ua_type() can be defined with some predefined ua types (like did by bootstrap with has the tablet, desktop and phone ua).

    Thank you, Stefano.

Topic Closed

This topic has been closed to new replies.

About this Topic