Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to do some simple split testing on a category page, but W3 Cache is causing some issues.

To do the split testing, I randomly select a layout (either grid or horizontal), then I store it in a $_SESSION variable so that the page is the same for that user while they're on the site.

Then on the category-slug.php page, I just do an if statement to determine what layout to display based on the value in the $_SESSION variable.

It is all working fine, except W3 Cache is caching the page. So the $_SESSION will have a grid layout value, but a horizontal layout will actually be displayed. Obviously this skews my data.

I'd rather not disable W3 Cache since it helps reduce our page load time. Anyone have any ideas?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

I ended up just putting variables to denote the layout in the conversion link.

For example, if the layout is a grid, the url is http://site.com/page-name/?g

It doesn't consistently let me switch layouts between users, but at least the data isn't being skewed by a $_SESSION variable reporting something differently than what is being seen by the user.

share|improve this answer

If you put something in the url to differentiate the layouts then it should cache them as different pages...other than that I can't think of anything that doesn't involve modification of W3Total Cache.

share|improve this answer

You can prevent W3 from caching the $_SESSION variable by adding it to Rejected Cookies in the page cache advanced settings.

This is the same method used to prevent W3 Total from caching shopping carts that use $_SESSION variables. See this post on the WP eStore support forums for more details.

share|improve this answer
Doesn't this just prevent the entire page from being cached as opposed to just the $_SESSION variable? The description underneath that setting says "Never cache pages that use the specified cookies." If that's the case, then since I have that $_SESSION created in the header, wouldn't that prevent all my pages from being cached? –  Kyle Feb 3 '12 at 16:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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