jcora jcora - 1 month ago 8
Javascript Question

Why isn't Google Chrome reloading my scripts?

So, I have a script called "engine", and after much headbashing and (futile) debugging, I've found out that GC simply isn't reloading it!

This is how I include it in the webpage (inside the

<head>
element):

<script type="text/javascript" src="engine.js"></script>


When a put 10
console.log("asdf");
's at the start of the script, it's like they aren't there. When I went to the "resources" tab in the GC console, I saw that no changes are being applied whatsoever to that script! Hlep? Would putting a
+ "?" + new Date()
at the end help?

Answer

It is possible that the script is cached so the old version is loading from cache. If you want to make sure you get a new version, you can force a browser reload, clear your browser cache or change the name of the script or put a different query parameter on the end of the filename.