title: ASP.Net MVC4 Mobile-Aware OutputCache
body: <p>I'm working on upgrading an application from MVC3 to MVC4 and noticed something that I assumed (hoped?) would "just work".</p>
  
  <p>CODE:</p>
  
  <pre><code>[OutputCache(Duration = 600, VaryByParam = "none")]
  public ActionResult Index()
  {
     return View();
  }
  </code></pre>
  
  <p>This is a textbook caching example for ASP.Net. Whenever a browser hits the page, it checks the cache to see if something exists, generates the view if not, and then sends the cached results.</p>
  
  <p>This works great; however, playing around with the Mobile view functionality of MVC4, I noticed that the above code does not check to see if the Request is from a Mobile Device.  So if I hit that route on a desktop, the desktop view will be displayed on my phone until cache is invalidated.  The reverse is true as well (if I first hit the page with a phone, the desktop will then see the mobile view instead).</p>
  
  <p>Is there a parameter that I could use to make this work like I hoped or am I looking at building a customer OutputCacheProvider?</p>