How to prevent the browser from displaying the cached version of the page?

One solution would be to add the QueryString variable to the url, which is a random guide, but that seems a bit dirty. Is there a parameter somewhere that prevents the browser from displaying the cached version of the page?

+5
source share
6 answers

You can add a meta tag like this.

<meta http-equiv="pragma" content="no-cache" />
+9
source

In our ASP.Net projects, we create BasePage, inherit all other pages. On the base page we have a function

Public Sub DisableCaching()
    With Response
        .Expires = 0
        .ExpiresAbsolute = Date.Today.AddDays(-1)
        .AddHeader("pragma", "no-cache")
        .AddHeader("cache-control", "no-cache")
    End With
End Sub

We call it on any page that we do not want to cache.

+6
source

ONE aproach "Expires Cache-Control Header".

Yahoo Best Practices (http://developer.yahoo.com/performance/rules.html)

:

* For static components: implement "Never expire" policy by setting far future Expires header
* For dynamic components: use an appropriate Cache-Control header to help the browser with conditional requests

( ) HTTP-, -. - Expires HTTP, , . Expires , , 15 2010 .

  Expires: Thu, 15 Apr 2010 20:00:00 GMT

Apache, ExpiresDefault, . ExpiresDefault 10 .

  ExpiresDefault "access plus 10 years"

, , "" , . .

, -, . Firefox CTRL + F5 CTRL + SHIFT + R.

, ,

+3

Cache-Control no-cache.

+3

:

Response.Cache.SetExpires(DateTime.Now.AddSeconds(360));
Response.Cache.SetCacheability(HttpCacheability.Private)
Response.Cache.SetSlidingExpiration(true);

Page.Response.Cache.SetCacheability(HttpCacheability.NoCache)

. question.

+2

QueryString url, ,

Why dirty? This is the most reliable way. This is not necessarily a guid, it may be the current time.

+1
source

All Articles