SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot jungerpants's Avatar
    Join Date
    Nov 2003
    Location
    Washington, DC
    Posts
    128
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WP-mobile and WP-supercache incompatibility

    Has anyone successfully used both WP-Mobile and WP-Supercache?

    Basically, the problem is that sometimes supercache will cache a browser version of a page and deliver it to mobile users. Other times, it will cache a mobile version of a page and deliver it to browser users.

    The only hints I can find involve putting a string in .htaccess to determine if the user is a mobile and then bypassing the supercache lines. But that doesn't seem to do the entire job.

    Help!

  2. #2
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well partially I do think I have done this, though not yet tested thoroughly, I did some modifications in the line you did suggested, as well in the wp-mobile module, since I thought the wp-supercache was too much for my brains.

    Code PHP:
    function akm_isNeedCaching(){
       if(isset($_COOKIE['akm_mobile']) && $_COOKIE['akm_mobile'] == 'true')
            return false;
    }
     
    function akm_superCache() {
        add_filter( 'do_createsupercache', 'akm_isNeedCaching' );
    }
     
    add_cacheaction( 'add_cacheaction', 'akm_superCache' );

    The above piece I added to the wp-mobile.php plugin code, then

    Code Perl:
    RewriteCond %{HTTP_COOKIE} akm_mobile=false

    once to the top section and once to the second section of .htaccess mod_rewrite rules thus the new htaccess rules for wp-supercache is now

    Code Perl:
    RewriteCond %{HTTP_COOKIE} akm_mobile=false
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{QUERY_STRING} !.*attachment_id=.*
    RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]
     
    RewriteCond %{HTTP_COOKIE} akm_mobile=false
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{QUERY_STRING} !.*attachment_id=.*
    RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]

    I really thought I should do atleast this before I run away tonight, though I am sitting down this weekend to write a case study of how we at Saturn Systemwares (www[dot]saturn[dot]in) did Kerala Online (keralaonline[dot]com) using wordpress.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •