I'm having a problem with the desktop version of my site (MVC4) being served up to mobile devices. I have output caching enabled for my homepage. In the cache directive I have VaryByCustom="Browser" set. I think the problem has to do with the fact that we give users the option to switch to the desktop version of the site.
Take the follow example:
- A user comes into the site (www.mysite.com) on a mobile browser and is redirected to the mobile home page (www.mysite.com/mobile).
- They then click a link to "View our full site" and are sent to the desktop homepage.
- This creates a cache entry for the mobile browser on the default homepage.
- All subsequent requests to the default homepage for that mobile browser will be served the desktop version of the homepage from cache.
Does my explanation of what is happening sound correct? If so, how do I fix it without disabling the cache or removing the “full site” option on mobile.
Update 1:
I want to add that I've had this setup for 51Degrees and caching for a long time, but only recently received reports of this problem. I did upgrade from MVC3 to MVC4 in the last few weeks. Could this be related to all the new functionality in MVC4 for browser detection and mobile view rendering?