Your solution for working with W3 Total Cache does not work. Consider the following example that I am currently experiencing myself…
You have added a cookie to exclude page caching when it exists but if the cookie never exists page gets cached. I visit a page in my desktop browser, no cookie, page gets cached. I visit the same page on my mobile device, no cookie is set so I am served the page that was cached when I visited it in my desktop browser. Result = Desktop view served to mobile device.
I’m not sure what the solution is but what has been suggested is not working