I'm using mobile tools to do simple theme switching (no redirection). Everything works great until I enable normal caching. Then, either everything or nothing is switched to the mobile theme.

Basically, without caching mobile browsers get the mobile theme and desktops get the desktop theme. But, when I enable normal caching, desktop and mobile both get the same theme (sometimes mobile, sometimes desktop, I haven't determined exactly which to make it consistent).

Basically, this makes the mobile theme switching not usable with normal Drupal caching.

(I'm running the latest, Nov 28, dev.)

Comments

twom’s picture

Status: Active » Needs work

Hi,

This is a known problem and is not only related to mobile tools. When caching is enabled, mobile tools never get's the chance to do something.

However there is a fix, but I have not had the time to really elaborate on the solution.

The current solution is to overwrite the default caching with your own caching file. Have a look at mobile_tools_cache.inc. You basically have to add this to your settings file:
$conf['page_cache_fastpath'] = FALSE,
$conf['cache_inc'] = './sites/all/modules/mobile_tools/mobile_tools_cache.inc',

In the mobile_tools_cache, you will see that the cache id is overwritten...

Any help in testing this is welcome!

mbiddlecombe’s picture

thanks for this. can i ask whether the default performance cache settings should still be set to 'normal' or 'off'

twom’s picture

Assigned: Unassigned » twom

Caching should be off....

I am working on better solutions.

Tom

twom’s picture

hmm... Not completely true what I just said. There are two scenarios:

1) If you do only theme switching and your desktop and mobile site share the same url, then your caching should be off. The reason is that Drupal uses the url as key in the cache.

2) If you have a specific mobile url and a desktop url, then you can use caching.

It is recommended to have scenario 2, where you have a desktop an mobile url.... However, most projects have trouble when they want to create 2 mobile templates (high end and low end) on the same mobile url...

Adaptive design could be a solution for this.

twom’s picture

I did some extra testing and using

$conf['page_cache_fastpath'] = FALSE;
$conf['cache_inc'] = './sites/all/modules/mobile_tools/mobile_tools_cache.inc';

does the trick of theme switching if you enable caching.

Pentacor’s picture

Thanks for that!

twom’s picture

Status: Needs work » Fixed

@Pentacor Thx for the feedback :)

Closing the issue now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

venusrising’s picture

Status: Closed (fixed) » Active

Wondering how good of an idea it is to mess with core caching?
Now if we have two urls like #2 would be have m.ourdomain DNS forward to same site url or how would that we set?
Would be need a whole other instance of Drupal installed or is this more of a redirect?
Thanks so much

minoroffense’s picture

Status: Active » Closed (won't fix)

1.x branch is no longer supported. Closing.

saurabh.dhariwal’s picture

https://drupal.org/comment/7156456#comment-7156456 would be the best possible solution for this.