title: Caching content only for non-authenticated users
body: <p>For a web-site, I want to cache the pages ONLY for users who are not authenticated - authenticated users do not get cached content (since they will be updating and need to see results right away).</p>
  
  <p>I know how to vary the cache for each user using VaryByCustom:
  <a href="http://visitmix.com/LabNotes/Using-VaryByCustom-With-OutputCache-in-ASPNET-MVC-To-Support-Caching" rel="nofollow noreferrer">Link1</a>
  <a href="https://stackoverflow.com/questions/1256317/how-not-cache-an-asp-net-user-control">Link2</a></p>
  
  <p>...But I can't figure out how to turn off caching entirely for authenticated users. </p>
  
  <p>What to do?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The code below has a problem if there is already a cached version of the page from an unauthenticated user. Basically the authenticated user will be served the unauthenticated view of things.</p>
  
  <p>However, this link here has solution that works: <a href="https://stackoverflow.com/questions/2109928/how-to-turn-output-caching-off-for-authenticated-users-in-asp-net-mvc">Link</a></p>