how can I force a browser to always load the newest version of index.htm when the page is loaded by entering the URL www.mydomain.com/index.htm or just www.mydomain.com in the b
You can use the code below to refresh or reload the currently loaded index page from a URL address entered directly into the browser's address bar, after a specific number of seconds, thereby forcing the browser to always reload the current document. In this case, the number of seconds has been set to 5:
<meta http-equiv="refresh" content="5" />
Please note that setting the number of seconds to 0 will cause the page to be automatically reloaded instantly, every time it is successfully downloaded.
To do this, you will need to perform some server-side coding along the way. You can use technologies like PHP or ASP.NET for this. I prefer coding with PHP, so here is a PHP-based example. First of all, make sure your INDEX is called "index.php", rather than "index.html" or "index.htm". Now take note of the following codes and make integrate this to your index.php file, while inserting your own page contents as well:
<html>
<?php
header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
?>
<head>
<script>
var sse = new EventSource("index.php");
sse.onmessage = function(event) {
document.write(event.data);
}
</script>
</head>
<body>
<!-- Insert HTML Codes -->
<?php
flush();
?>
</body>
</html>
OK, apparently no-cache was not enough. The following does the trick:
<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />