Hello,

This module works only for registered users (without Drupal cache). Is there a solution to this problem?

Thank you in advance!

Comments

adhisimon’s picture

If I disable "Cache pages for anonymous users" and clear the cache, it looks work for a while. But after several hours, It looks like to use drupal cache again.

I don't like to use different subdomain (m.****, mobile.****). And I think it's the purpose of this module to enable mobile version without using different subdomain.

Clément’s picture

Yes, I totally agree with you!

But Drupal is not Wordpress! With no cache, Drupal is really slow. For now the module does not work when cache is enabled.

quiptime’s picture

Hello Clément,

You post this bug on three modules with same content:

Your message

This module works only for registered users (without Drupal cache)

is to simple and not really constructive. A module maintainer can not understand the problem.

And, please no Drupal vs Wordpress discussions (see #2).

Clément’s picture

I solved the problem by myself.

Here is my solution:

Installing the module: Dynamic Cache

+

/**
 * hook_boot()
 */
function hook_boot() {
  $browser = browscap_get_browser(NULL);
  if(isset($browser['ismobiledevice']) and $browser['ismobiledevice']) {
    $GLOBALS['conf']['cache'] = FALSE;
    drupal_page_is_cacheable(FALSE);
    //echo 'Is mobile';
  }
}
SewFresh’s picture

A fix to this is just what I was looking for! However, I'm a coding newbie and was wondering, after you install the Dynamic Cache module, where do you put that code you mentioned for the fix?

Thanks!

Anonymous’s picture

Is this not just programatically disabling the cache for all mobile devices? It's a work-around, but it doesn't really seem to be a fix. If your site is mainly viewed on mobiles, you might as well just turn off caching.

extde’s picture

#4 is not good solution.

I still want cache.
I am using Varnish cache (external)

Here are steps:
1) enable "external page cache" (http://drupal.org/node/797346)
used following snippet:

if (!class_exists('DrupalFakeCache')) {
  $conf['cache_backends'][] = 'includes/cache-install.inc';
}
// Rely on the external cache for page caching.
$conf['cache_class_cache_page'] = 'DrupalFakeCache';

2) modify vcl_hash to separate different presentations for same URL but different user-agent (http://bridgecitystudio.com/tutorials/configuring-varnish-cache-user-age...)

sub vcl_recv {
  ...
  # mobile devices detection
  call detect_device;
  ...
}

sub detect_device {
  # Define the desktop device
  set req.http.X-Device = "desktop";

  if (req.http.User-Agent ~ "iP(hone|od)" ||
      req.http.User-Agent ~ "Android" ||
      req.http.User-Agent ~ "iPad") {
    # Define smartphones and tablets
    set req.http.X-Device = "smart";
  } elseif (req.http.User-Agent ~ "SymbianOS" ||
            req.http.User-Agent ~ "^BlackBerry" ||
            req.http.User-Agent ~ "^SonyEricsson" ||
            req.http.User-Agent ~ "^Nokia" ||
            req.http.User-Agent ~ "^SAMSUNG" ||
            req.http.User-Agent ~ "^LG") {
    # Define every other mobile device
    set req.http.X-Device = "other";
  }
}

sub vcl_hash {
  hash_data(req.url);
  if (req.http.host) {
    hash_data(req.http.host);
  } else {
    hash_data(server.ip);
  }
  # add User-Agent to hash for mobile devices
  hash_data(req.http.X-Device);
  return (hash);
}

3) modify vcl_deliver - remove Etag from HTTP Response (not sure this has an effect, looks like this might help with browser caching issues when switching user-agent)

sub vcl_deliver {
  ...
  unset resp.http.Etag;
  ...
}
MakeOnlineShop’s picture

Issue summary: View changes

Hello,

Can you confirm that the last message posted is the solution ?

Thank you.

compsyguy’s picture

I found something that fixed the theme switch for cached pages for anonymous users for me.

The problem was with url alias chains - if a page had a url alias, that points to another alias, then the switching won't happen.

The fix I did was to just make sure that all the links had a direct alias to the node/$nid and that seems to work.

Nevermind, that doesn't work.