0

Mono MVC2 application uses controller below to cache order page in browser.

If F5 is pressed in browser, old page is still returned to browser. How to return fresh page if F5 is pressed ? It looks like page is cached in server but OutputCacheLocation.Downstream must cache page only in borwser. Is this bug?

    [Authorize]
    public class DetailController : ControllerBase
    {
        [OutputCache(Location = OutputCacheLocation.Downstream, Duration = 20 * 60,VaryByParam = "_entity")]
        public ActionResult Index(string _entity, int? orderId)
        {
...
Andrus
  • 26,339
  • 60
  • 204
  • 378

1 Answers1

1

I think you may be missing the whole point of caching. Pressing F5 will continue to return the cached page until it has expired (20 mins in your case). If you want to force the server to send the page again you would need to do a hard refresh e.g. Ctrl + F5

James
  • 80,725
  • 18
  • 167
  • 237
  • `OutputCacheLocation.Downstream` means that server should *not cache* the page. 20 min is *only browser* cache time. Pressing F5 must return new page from server without any cache. I tried Ctrl+F5 in IE9 also but problem persists. – Andrus Oct 29 '12 at 15:43
  • @Andrus exactly, the server isn't caching the page here the *browser* is. Pressing F5 will do nothing but pull the page from the *browsers* cache until it expires. The only way around this is to either clear the cache or do a hard-refresh. – James Oct 29 '12 at 15:47
  • After pressing F5 Chrome developer tools Network shows that page is retrieved from server. It is *not read* from browser. However old version of page is returned. How to force server to return new page version? – Andrus Oct 29 '12 at 16:08
  • @Andrus what exactly is it on the page you are expecting to have changed? If Chrome is telling you the page has came from the server then it's more than likely something else on the page has been cached e.g. do you rely on JS executing or something? – James Oct 29 '12 at 16:14
  • orderId parameter is different. It should return other order corresponding to orderId parameter. Currently it always returns the order which is first time opened after application run. Javascript is not used to render order header, it is simple form containing input elements – Andrus Oct 29 '12 at 16:21
  • Yes, URL contains new orderid. _entity parameter is also ignored. Even for different _entity parameter values in query string same order opened in first itme is still returned. – Andrus Oct 29 '12 at 16:26
  • I can send you url and logon data if you want – Andrus Oct 29 '12 at 16:35