ASP.NET MVC 2 disable cache for browser back button in partial views

Posted by brainnovative on Stack Overflow See other posts from Stack Overflow or by brainnovative
Published on 2010-05-15T17:44:07Z Indexed on 2010/05/15 19:14 UTC
Read the original article Hit count: 1233

I am using Html.RenderAction<CartController>(c => c.Show()); on my master Page to display the cart for all pages. The problem is when I add an item to the cart and then hit the browser back button. It shows the old cart (from Cache) until I hit the refresh button or navigate to another page.

I've tried this and it works perfectly but it disables the Cache globally for the whole page an for all pages in my site (since this Action method is used on the master page). I need to enable cache for several other partial views (action methods) for performance reasons.

I wouldn't like to use client side script with AJAX to refresh the cart (and login view) on page load - but that's the only solution I can think of right now.

Does anyone know better?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc-2