0

I am using the Mobile theme module in order to load a specific theme in the mobile devices. when I enable caching, the module does not work properly.

More specific, when a page is first visited from a a mobile device for the first time, it will always come up with the mobile theme, even when it is not visited from a mobile device. When a page is visited from a desktop device for the first time, it will always come up with desktop theme even for mobile devices.

1

I don't think there's a straightforward solution to this in Drupal7 but there are some workarounds available:

  1. Use JavaScript to detect and do the switch
  2. This issue happens because D7 uses page URL as page's cache id (CID). To distinguish different devices for same page, you'll need to alter the CID somehow so it looks something like CID_phone, CID_tablet and CID_desktop. I used mobile_detect module before and know there are some patches on this. Do keep in mind there's a side effect that this approach will triple the amount of CIDs in you database table.
  3. If you use Varnish you can try something like this
  • I can't use javascript since I must use two different theme for pc and mobile. Mobile detect and all of the same modules suffer from the same problem as it is drupal's core problem. I am using lite speed so the varnish solution isn't ok. – shekoufeh Mar 6 '17 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.