Reputation: 1704
i want to avoid browsing cache while viewing a document. Please help me solve this issue by using java script or by any other method.
Regards,
Arun
Upvotes: 0
Views: 102
Reputation: 11751
Since you asked "in JavaScript" I'll add that you need to use a different URL each time you view the document in JavaScript. E.g.
<a href="/a-document" onclick="this.href += '?' + new Date()">
(this is far from robust, it just illustrates the basic principle of the technique)
You'd only really do it this way if you were unable to control the server (e.g. if you aren't the owner).
Upvotes: 1
Reputation: 37029
Add the following header to your response:
Cache-Control: no-cache
Upvotes: 0
Reputation: 46008
Set content-expiration
header in your response.
var cache = HttpContext.Curent.Response.Cache;
cache.SetExpires(DateTime.UtcNow.AddDays(-1));
cache.SetValidUntilExpires(false);
cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
cache.SetCacheability(HttpCacheability.NoCache);
cache.SetNoStore();
Upvotes: 3