Currently, I'm in a state where my code works, but only when cache is disabled in DevTools.
My code is
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<script type="text/javascript">
function refresh() {
var req = new XMLHttpRequest();
console.log("Grabbing Value");
req.onreadystatechange = function () {
if (req.readyState == 4 && req.status == 200) {
document.getElementById('live').innerText = req.responseText;
}
}
req.open("GET", 'live.txt', true);
req.send(null);
}
function init() {
refresh()
var int = self.setInterval(function () {
refresh()
}, 10000);
}
</script>
</head>
<body onload="init()">
<div id="main">
<span id="live"></span>
</div>
</body>
</html>
However, the requested file (live.txt) gets cached by the browser, making it that the file won't ever update, unless disabled by Chrome DevTools. How do I prevent the cache?
Edit: didn't know someone else had said this.