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 currently working on a website using WordPress, Headway, Modernizr and W3 Total Cache. The problem I'm having is that W3TC is caching the body tag, which means that this isn't being updated depending on the users browser by Modernizr.

An example of how this is a problem is that modernizr adds the 'firefox' body class, if this is then cached then in chrome, we have that same 'firefox' body class which makes any browser specific css inaccurate.

I have tried using <!-- mfunc -->any PHP code<!-- /mfunc --> that I got from this answer

The code looks like this

<!-- mfunc -->
headway_page_top();
<!-- /mfunc -->

I have experimented with using the same mfunc wrapper inside the headway_page_top() function so that it is directly around the body tag without success. The error I get comes from W3TC and says 'Unable to execute code:' and then all the markup wrapped by the mfunc is printed out (in debug mode). This also happens with debug mode disabled.

This call is happening inside wp-content/themes/headway-2012/header.php, and I have added that path to the 'Cache exception list' inside the W3TC Page Cache settings to no avail.

Does anyone have any suggestions as to how I can have the page cache run side by side with modernizr and not have this problem?

EDIT: This problem isn't to do with Modernizr at all, I jumped the gun in thinking that it was. Headway is adding the body class in on its own and isn't using modernizr to do so. The problem is using W3TC and its fragment so that the body class remains dynamic. I haven't managed to get the fragment caching working at all, or find much documentation on it.

Is fragment caching a feasible solution? I seem to be running out of possible solutions.

share|improve this question
    
I might have been a bit confused earlier. Headway is putting the body class together. I'm going to switch it to modernizr to see if that fixes the problem. –  supajb Jan 9 '12 at 0:51
    
Close-voted as too localized. As Headway is a commercial Theme, you should consult the support offerings of the developer, Headway Themes. –  Chip Bennett May 7 '12 at 19:03

1 Answer 1

Caching shouldn't affect Modernizr since it's a client-side script and will run every time the page is visited.

I haven't used Headway but from what you describe it sounds like a server-side script in Headway is sniffing the browser and that's the result being cached.

Does that make sense?

share|improve this answer
    
You're right, it isn't modernizr being cached but a headway call. I was a bit rushed when I wrote the initial question and my edits weren't very clear. The fragment caching on the W3TC plugin however isn't working for me around that call. –  supajb Jan 12 '12 at 3:43

Your Answer

 
discard

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.