safari not using edited js files when reloaded with caches disabled

When a javaScript file is edited and reloaded to the server and the page is reloaded the unedited version of the javaScript file is used.

The Develop -> Disable Caches is checked, and I even do an Empty caches before reloading.

But Safari uses the cached content.

In desperation I have removed all content from the file and saved it, but Safari will not use the edited file.

I can change the file name, but unless I have to use a unique filename each time an edit is made. Reusing an already used filename and Safari uses the cached version of the file.

iMac (Retina 5K, 27-inch, Late 2014), Mac OS X (10.0.x)

Posted on Dec 13, 2015 2:18 AM

Reply
4 replies

Dec 13, 2015 6:19 AM in response to dennisjn

Safari 9


Safari/Preferences/Advanced - enable the Develop menu, then go there and Empty Caches. Quit/reopen Safari and test. Then try Safari/History/Show History and delete all history items. Quit/reopen Safari and test. You can also try try Safari/Clear History…. The down side is it clears all cookies.Doing this may cause some sites to no longer recognize your computer as one that has visited the web site. Go to Finder and select your user/home folder. With that Finder window as the front window, either select Finder/View/Show View options or go command - J. When the View options opens, check ’Show Library Folder’. That should make your user library folder visible in your user/home folder. Select Library./Caches/com.apple.Safari/Caches.db and move it to the trash.


Go to Safari Preferences/Extensions and turn all extensions off. Test. If okay, turn the extensions on one by one until you figure out what extension is causing the problem.


Safari Corruption See post by Linc Davis


10.10 (Safari 8)


Safari/Preferences/Advanced - enable the Develop menu, then go there and Empty Caches. Quit/reopen Safari and test. Then try Safari/History/Show History and delete all history items. Quit/reopen Safari and test. You can also try try Safari/Clear History and Web Site Data. The down side is it clears all cookies.Doing this may cause some sites to no longer recognize your computer as one that has visited the web site. Go to Finder and select your user/home folder. With that Finder window as the front window, either select Finder/View/Show View options or go command - J. When the View options opens, check ’Show Library Folder’. That should make your user library folder visible in your user/home folder. Select Library./Caches/com.apple.Safari/Caches.db and move it to the trash.


Go to Safari Preferences/Extensions and turn all extensions off. Test. If okay, turn the extensions on one by one until you figure out what extension is causing the problem.

Dec 13, 2015 2:40 PM in response to Eric Root

I tried all those suggestions and nothing worked.

When I look at the file in the resources, the javaScript file contents are the unedited version.

The only way to have it load the current version of the file is to either shut down and restart the computer or to close Safari, reopen Safari and visit other sites and then return to my project.

But the Php files were being reloaded so I used the following trick to force a reload of the file

<script>

document.write('<scr'+'ipt src="http://www. path /js/_guest_user.js?'+Math.random()+'" type="text/javascript"></scr'+'ipt>');

</script>

This loads the javaScript file every time the page reloads.

Dec 14, 2015 2:18 PM in response to dennisjn

Using the <script>document.write in the html head works fine.

And using document.write('<link href="css/main1.css?'+Math.random()+'" rel="stylesheet" type="text/css">'); works for style sheets.

But when sending a http request the cached file is always used regardless of the Disable caches being checked or clicking the Empty caches menu item.

The only way to ensure that the latest edit is being loaded seems to require restarting the computer.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

safari not using edited js files when reloaded with caches disabled

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.