Narain Mittal
Narain Mittal

Reputation: 1160

Browser Cache control: Different behavior among Internet Explorer and Chrome

I have been working on a problem to prevent serving cached server pages on click of browser back button. Went thru This question and setting appropriate response headers (below) work, but there is inconsistent behavior between IE and chrome.

response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "0");

IE: Serves a 'Webpage has expired' once I go back to a page using back button

Chrome: Doesn't say page expired, and doesn't serve a cached page either, but does a new server request even on a back button - sort of like hitting refresh.

My question: Is this how they are meant to respond to the headers and is there a way to achieve a consistent result? The primary intention is to avoid serving cached pages on back button across browsers.

Upvotes: 2

Views: 755

Answers (1)

Narain Mittal
Narain Mittal

Reputation: 1160

Well, actually I had it figured out. The behavior on Chrome was different because of a browser setting on Chreme Dev Toolbar to explicitly disable cache as in the screenshot below. And this caused the page to hit the server instead of showing a page expired.

If I disable this option, I do see the 'Confirm form re submission' page.

Chrome Dev toolbar

Upvotes: 1

Related Questions