I have a HTML page. The problem is that I do not want to have the users to refresh the page each time I put on new content.
I have the following code in order to make sure that the page is not cached:
<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"/>
The problem is, I still need to do a refresh on the page in order to get the most current content to show up. Am I doing something wrong? Should I be using some other tags?
Here's how... When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache.
Setting a short cache time By asking the Web browser to only cache the file for a very short length of time, you can usually avoid the problem. That's all it takes. The next time the visitor views the file, more than a second will have passed, so the browser won't use the outdated cached copy.
An alternative to the Cache-Control HTTP header is to use META HTTP-Equiv tags. These tags produce the same result as the equivalent HTTP header when used within your channel pages and are processed by the M-Business Sync Server and displayed in M-Business Client.
Implementing user personalization in scripts allows caching of the page's HTML. Then the scripts can modify the page after loading asynchronously. Beyond using JavaScript for personalization, The Gap is caching HTML.
The Codesnippet you showed makes the browser load the website everytime it accesses it, which is useful if you perform frequent updates, but still have a static page.
<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"/>
In case you want it to perform live updates, like it does for example in a (g)mail account, you need to make it refresh (parts of the page) itself. Use Javascript in this case, like it is shown in this question or an ajax call.
$('#something').click(function() { location.reload(); });
The values you have there are OK, but meta http-equiv
is highly unreliable. You should be using real HTTP headers (the specifics of how you do this will depend on your server, e.g. for Apache).
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