1

I have a form in c#/.net that uses PRG after someone changes the quantity of items they want to purchase. I noticed that in Firefox and IE, you can change the quantity as many times as you want and then press back and it will take you back to the previous screen. However, in Google Chrome, if you press back (after adjusting the quantity multiple times) it will stay on the page and just re-adjust to previous quantities (eventually it will go back to the previous screen). I'm hoping there's a way to make it not re-adjust the quantities and go back to the previous page right away like IE and Firefox do. Anyone know if this is possible?

I'm not very good at explaining my problems so I hope this makes sense, thanks!

EDIT: I have tried turning off the cache and it still does not work

user1758415
  • 371
  • 1
  • 5
  • 13
  • Assuming you have set all HTTP cache headers correctly, this might be related to the back-forward cache. I've seen this behavior in Safari. Safari is based on Webkit, same as Chrome (until the recent branch). – Tim M. Sep 12 '13 at 17:13
  • So the solution might just be out of my reach? This seems related to my problem: https://bugs.webkit.org/show_bug.cgi?id=38690 "It looks like this is related to the code in MainResourceLoader::willSendRequest. There is a call to isPostOrRedirectAfterPost, and if that returns true, we force the cache policy to ReloadIgnoringCacheData. We then modify the ResourceRequest of the DocumentLoader." – user1758415 Sep 12 '13 at 17:25
  • The back-forward cache is designed to reconstruct the last state of the page without making any requests. First, make sure that you are setting HTTP cache headers correctly (post code if you need help validating that you have done it correctly). This will fix a variety of behaviors, and the back-forward cache will respect these headers in most browsers. If your headers are correct but the browser still rebuilds the page from old values, you can try [these solutions](http://stackoverflow.com/questions/7248111/how-to-prevent-content-being-displayed-from-back-forward-cache-in-firefox). – Tim M. Sep 12 '13 at 17:33
  • That link is for Firefox, but it's applicable to the back-forward cache in any browser. Also see [here](https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching) for catching cache events (and possibly defeating them). Typically you only want to do this as a last resort, i.e. make sure caching is disabled elsewhere. – Tim M. Sep 12 '13 at 17:33
  • I can post the code I use as well but to test it, I did "inspect element", settings, and checked "disable cache (while DevTools is open)" then I tested it with DevTools open and it still didn't seem to work. This should have disabled the cache. – user1758415 Sep 12 '13 at 17:39
  • Here is what I used to disable the cache: Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0. Response.AppendHeader("Expires", "0"); // Proxies. – user1758415 Sep 12 '13 at 17:40
  • Okay. Then try catching the [pageshow event](https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching#pageshow_event) and see if the page is being loaded from the back-forward cache. – Tim M. Sep 12 '13 at 17:43
  • Does this only work for Firefox? Do you have an example of how to use this? – user1758415 Sep 12 '13 at 18:43
  • `window.onpageshow = function (e) { if (e && e.persisted) { alert("back forward cache hit"); } };`. If you can post a [JS Fiddle](http://jsfiddle.net) that recreates the problem, people will be more likely to help. It may have nothing to do with caching. – Tim M. Sep 12 '13 at 19:18
  • I'm not getting an alert. I went to chrome://cache/ in my browser (made sure it was empty) then I went to inspect element, turned off the caching and then went to my page. When I refreshed chrome://cache/, there is still cache being added. Do you think the browser is still caching and maybe I haven't correctly prevented it from caching? – user1758415 Sep 12 '13 at 19:33
  • Sounds more like a history issue then. When you change quantities, does it change the URL? (e.g. a hash) – Tim M. Sep 12 '13 at 19:36
  • No, same URL when quantity is changed. – user1758415 Sep 12 '13 at 19:41

0 Answers0