After hours, I finally found the cause why the difference of after and before count of rows does not updating inside an HTML element. It is because the external source (/count
) that I call in every 5 seconds are being cached. To expand the problem, the /count
page is composing of the real time number of rows. If ever a webpage is initially loaded, the function loadXMLCount
takes an argument 2865
rows as its initial values. On the other hand, after 5 seconds, considering there's no row being added within 5 seconds, the /count
will also have a value of 2865
row. The initial call of the function loadXMLCount
will return the difference of 2865 - 2865 which is 0. On the second call, if the /count
will now have 2867
rows, two rows were added between 5 - 10 seconds. The result should be 2867 - 2865 = 2. The problem I'm facing is that I can't pull the latest value of /count
(2867) within the main html page. I already tried the meta header inside /count
page but I had no luck. When I tried to reload the /count
page the main page will also be updated (could have updated the save on disk in Chrome). How can I avoid external page to be cached or to be save on disk (I found it on Chrome dev console) and load it without forcing to reload the /count
page?
<script>
...
...
xhttp.open("GET", "/count", true);
xhttp.send();
}
setInterval('loadXMLCount(2865)',5000);
</script>