0

I would like to start first with the fact that I know that there are more than several hundred questions in regards to this topic. However, after trying and trying I still do not have a solution to my issue. That is why I would be really grateful if someone can help me out.

I will tell you ver briefly what I am trying to do. I have one file uploaded on my hosting (public_html) folder named index.html.

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
    </head>
    <body>
        Random text.
    </body>
</html> 

What I would like to achieve is that the moment I change the "Random text." to something else and go to www.mydomain.com/index.html to be able to see the change I made.

I have tried to following solutions:

Number One:

$(document).ready(function() {
  setInterval(function() {
    cache_clear()
  }, 3000);
});

function cache_clear() {
  window.location.reload(true);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

Number Two:

<IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</IfModule>

Number Three

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

but for my disapointed none of these methods was a solution to my problem.

George Smith
  • 415
  • 8
  • 25
  • 1
    #3 is the best choice, but since `.html` files are static, you may not have any luck. The best solution would be to use a server-side file type that your server supports, like .php. – Scott Marcus Dec 18 '18 at 22:04
  • @ScottMarcus Hmm... I have just created a php file called bravo.php and pasted the content of my html file in it plus adding the number 3 meta tags into it, but the result is still the same. – George Smith Dec 18 '18 at 22:09
  • 1
    Are you accessing the .php file from a server that is configured to serve .php files? – Scott Marcus Dec 18 '18 at 22:10
  • @ScottMarcus I think, I do. I am using a paid hosting from a very reputable hosting provider, which I will not name, because I do not want to advertise here. I have tested several CMS php based system and everything was working fine. – George Smith Dec 18 '18 at 22:14
  • 1
    Possible duplicate of [Avoid caching of the http responses](https://stackoverflow.com/questions/9884513/avoid-caching-of-the-http-responses) – symcbean Dec 18 '18 at 22:50
  • Cache-busting from JavaScript is technically possible, but this is not how to do it. The answers are in the many posts you say you have read - but nothing is going to work if your cache already contains non-expired content – symcbean Dec 18 '18 at 22:52

0 Answers0