2

Is it even possible to do this?

The goal is to group our visitors:

Group A sees Theme A
Group B sees Theme B

I am able to achieve this goal through cookies. But when caching is enabled (i.e. Site config > Performance > On), things are messed up. This is what happens:

1) Group A visits Page-1
-- Page-1 is not cached yet.
-- Cookies are properly checked.
-- Page-1 is displayed using Theme A


2) Group B visits Page-2
-- Page-2 is not yet cached.
-- Cookies are properly checked.
-- Page-2 is displayed using Theme B


3) Group A visits Page-2
-- Page-2 is already cached.
-- Cookies are ignored
-- Page-2 is displayed using Theme B (when it should be displayed using Theme A)

So now what I am thinking is, instead of using cookies, I'll use separate cache for each group.

Is this even possible? :S If not, any recommendations are welcome.

Inputs will be highly appreciated. Thanks!

6
  • What do you mean by group ? Organic Group or Group of users ?
    – Anil Sagar
    Commented Oct 8, 2012 at 7:06
  • visitors are randomly selected if they are gonna be under group A or B, or no group at all
    – Bibokid
    Commented Oct 9, 2012 at 7:03
  • just out of curiosity, does using the cache_clear_all() function help.. though it might beat the purpose of enabling caching in your case to me it appears it could solve the problem though in an inefficient manner... Commented Oct 9, 2012 at 7:30
  • Hi optimus. It will, but I will have to run that code on every page, which is almost the same as disabling caching.
    – Bibokid
    Commented Oct 9, 2012 at 7:56
  • So you're just looking for a method to perform A/B testing?
    – Chapabu
    Commented Oct 9, 2012 at 8:02

2 Answers 2

0

Checkout Cache page based on cookie value and URL

Long story short what you want can be done. Depends on how you want to do it :)

0
0

Ok so here's what I did.

I extended drupal's cache.inc by including this line on settings.php

$conf['cache_inc'] = sites/all/modules/mycustom_module/my_custom_cache.inc';

I basically copied drupal's cache.inc and pasted it in my module's folder, renamed it, and then added a few lines of code where I altered how $cid's are generated. This way I am able to create $cid variants of cache depending on the theme

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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