Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load index.html every time from the server and NOT from cache

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!

like image 874
Pulkit Mittal Avatar asked Nov 10 '12 10:11

Pulkit Mittal


People also ask

How do I stop index HTML from being cached?

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.

Does HTML get cached?

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.

Does Cloudflare cache index HTML?

Cloudflare doesn't cache html by default.

How do I enable HTML cache?

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.


1 Answers

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.

like image 172
doniyor Avatar answered Sep 18 '22 12:09

doniyor