I'm developing a web app and having a weird issue where my testers' browsers are fetching newer JavaScript files but using cached HTML files.
My scripts have query parameters, which I updated when I push a new HTML file, to ensure the browser isn't using older cached code:
<script src="code.js?version=1></script>
When I update code.js, I also increment the version parameter in the script tag on page.html.
My testers are hitting errors on Chrome on Android. When Chrome is reopened from the background after I push a new version of both files, apparently Chrome fetches the new code.js but uses the cached page.html.
This is problematic when the new JavaScript references newly added HTML elements that don't exist in the cached version of page.html.
Under what circumstances would the browser re-fetch a JavaScript file when, as far as it knows, the HTML page itself hasn't been changed? The HTML file is still pointing to the old version query string, so shouldn't that exact path still exist in the cache?
I've since migrated to using RewriteMod to let me inject version numbers into filenames, but I'd still like to understand why files with query strings aren't being retrieved from the cache when the query string hasn't changed.