Search code examples
hashinternet-explorer-11back-button

Prevent IE11 for using cached API response when pressing browser's "Back" button


I am writing a React application, using hash routing (react router v3). I have discovered a bug where IE11 is using the cached API response when pressing the browser's 'Back' button. I am using the fetch API with a polyfill

The headers I am sending with the initial request are as follows:

const headers = {
    'Accept': 'application/json',
    'cache': 'no-store',
    'Expires': 0,
    'cache-control': 'no-cache',
    'Content-Type': 'application/json',
}

Any one know how to force IE11 to make a new API request in this scenario?


Solution

  • I ended up adding a query parameter with "expires=" + Date.now() so that it will always be unique and cache will not be used. This approach works for IE11.