1

We have a JS script that might change over each request. We do not have the opportunity to change the src of the script tag. However, we do have availability to change the serverside script that outputs the JS.

Why isn't this script being reloaded on iOS after you press the back button?

In php we sent out these headers:

header("Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0"); // HTTP 1.1.
header('Last-Modified: '.gmdate('D, d M Y H:i:s \G\M\T', time()));
header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time()));
header('Access-Control-Allow-Origin: *');
header('Pragma: no-cache'); // HTTP 1.0.
header('Content-Type: application/javascript; charset=utf-8');//lets pretend it to be a JS file

What is missing to force an reload of the js file?

Charles Response headers on the first load

UPDATE:

Page 1 is loaded with script tag

After an anchor click on page 1 customer is redirect to new page; page 2. script src="some.js etc etc. some.js is dynamically generated on the server and DOES output something.

Hitting the back button, will lead to page 1. But the some.js is showing the content of page 2. Strange????

Peter Fox
  • 1,239
  • 2
  • 11
  • 31

1 Answers1

0

Back button is actually not making page to load if it is still in RAM cache. You can reload your JS binding to the window's onpageshow event.

Take a look here:

Community
  • 1
  • 1
oleynikd
  • 896
  • 13
  • 33