Fascgi AND W3 mobile and desktop caches - desktop cache corrupted with mobile elements

I use wp_is_mobile to detect whether the user is mobile or not and display certain elements on the page.

I run nginx with fastcgi cache and have setup 2 seperate caches using this method.

I recently moved to a new URL on the same server and something strange is happening.

Sometimes the desktop version of a page will have no sidebar (sidebar is disabled for mobile) and show both desktop and mobile page elements! Then if I go to the mobile version of the page, it will show the mobile version only, as normal.

So what is happening is somehow, only some (not all pages have this) desktop cached pages are becoming “corrupted” and somehow containing both mobile and desktop elements.

I have no idea how this could be happening. Any assistance much appreciated.

Setting set $skip_cache 1; for all requests fixed the problem. As does purging the cache.

This issue also appears with the above setup (fast_cgi DISABLED) and trying to use the page cache function in W3. In these cases when I purge the W3 caches and turn off page cache it resolves itself.

Something to do with memcached?

No ideas anyone?

I recently moved servers and was going through all the settings and found that I had actually commented out add_header rt-Fastcgi-Cache $upstream_cache_status; in nginx.conf by mistake and also had browser cache in W3 enabled.

It’s only been a short time, but the issue appears to be fixed.

Could this have been the cause?

EDIT: the issue is still there. Damn…