I have a webpage index.html hosted on a particular server. I have pointed example.com
to example.com/index.html
. So when I make changes in index.html and save it, and then try to open example.com, the changes are not reflected. Reason that the webpages are being cached.
Then I manually refresh the page and since it loads the fresh copies and not from cache, it works fine. But I cannot ask my client to do so, and they want everything to be perfect. So my question is that is there a trick or technique as to how I can make the file load every time from the server and not from cache?
P.S: I know the trick for CSS, JS and images files, i.e. appending ?v=1
but don't know how to do it for index.html.
Any help would be appreciated. Thanks!
Server Configuration config we specify that we don't want to the index. html to cache by setting the cache-control , Pragma and Expires request headers as well as the max-age to 0.
The browser will retrieve the HTML page from the web server but consult its cache for the static assets (JavaScript, CSS, images). We can see the difference cache makes when we refresh the Wikipedia page: The data transferred went down to 928 bytes — that's 0.3% the size of the initial page load.
Cloudflare doesn't cache html by default.
To use cache-control in HTML, you use the meta tag, e.g. The value in the content field is defined as one of the four values below. HTTP 1.1. Allowed values = PUBLIC | PRIVATE | NO-CACHE | NO-STORE.
by this:
<meta http-equiv="expires" content="0">
Setting the content to "0" tells the browsers to always load the page from the web server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With