Reputation: 261
I try to disable the html url browser cache using programmatically. I am developing as a site using asp.net, I need to disable the html url browser for the security reason. I tried many ways to disable the cache but none seems to work. Any ideas?
<iframe id="iframe" src="http://www.phy.mtu.edu/basiccomputing/sample.html" runat ="server" width="200" height="300"></iframe>
Upvotes: 0
Views: 594
Reputation: 1755
try
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1))
. This site has something that can be quite helpful.
Upvotes: 0
Reputation: 60438
As far as it's a html file you want to work with, a easy solution is to append a random number and the end of your url like this
<iframe id="iframe" src="http://www.phy.mtu.edu/basiccomputing/sample.html?12345" runat ="server" width="200" height="300"></iframe>
I don't know wich view engine you are using, so i cant provide a sample you simple copy and paste.
You have to replace ?12345
with a random number like new Random().Next().ToString()
If you call a asp.net page you can control it with
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Response.Cache.SetNoStore();
more informations about that:
hope this helps
Upvotes: 1
Reputation: 850
You could attach a random parameter to the URL so the browser thinks it's a different page every time.
http://www.phy.mtu.edu/basiccomputing/sample.html?rand=[INSERT RANDOM HERE]
Upvotes: 0