ASP. NET clear page Cache
(1) response. Buffer = true;
Response. expiresabsolute = system. datetime. Now. addseconds (-1 );
Response. expires = 0;
Response. cachecontrol = "no-Cache ";
Response. addheader ("Pragma", "No-Cache ");
(2) HTML Method
<Head>
<Meta HTTP-EQUIV = "Pragma" content = "no-Cache">
<Meta HTTP-EQUIV = "cache-control" content = "no-Cache">
<Meta HTTP-EQUIV = "expires" content = "0">
</Head>
(3) When you call the original page again, you can send the following parameter to the page: href = "*****. aspx? Random ()"
1. Cancel Cache
(2) Client Cancellation
<HTML>
<Head>
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "cache-control" content = "no-Cache">
<Meta http-equiv = "Pragma" content = "no-Cache">
</Head>
(3) Cancellation of service appliance:
Server:
Response. Buffer = true;
Response. expiresabsolute = datetime. Now. adddays (-1 );
Response. cache. setexpires (datetime. Now. adddays (-1 ));
Response. expires = 0;
Response. cachecontrol = "no-Cache ";
Response. cache. setnostore ();
In global:
Protected void application_beginrequest (Object sender, eventargs E)
{
Httpcontext. Current. response. cache. setnostore ();
}
<% @ Outputcache location = "NONE" %>
Page Base class:
Public class pagebase: Page
{
Public pagebase (){}
Protected override onload (eventargs e ){
Response. cache. setnostore ();
Base. onload ();
}
}
The simplest way
To learn about csdn, add some useless parameters randomly after the URL, for example:
Http: // xxx/XXX/xxx.jpg? P = xxx
Ie uses URLs to control the cache.
(4) Can I set web. config?
2.
(1) What is the difference between the client cache and the cache object we often use in code? When we only use the client cache, does it affect the cache we use in the code!
There are two completely different things. The cache object is used to cache things for you. The advantage is that it will automatically clear expired things. Client Cache is an HTTP specification used to cache web pages on the client. Sometimes we need the client cache to increase the browsing speed and reduce the server load, but sometimes we need to disable the cache on the client, to prevent the client from seeing expired Information
(2) how to remove the value from the cache when the client browser is closed. This can be done when the user logs out normally, but how can the user directly close the browser?
<Body onbeforeunload = "window. Open ('Clear. aspx ','', 'top = 4000') ">
(3) 1. Page. cache, context. cache, and httpruntime. Whether the cache references the same cache object.
2. What is the difference between them?
3. What are their application scenarios?
They refer to the same object, in a request, page. cache and httpcontext. current. the cache is effective. The difference between the two is generally determined by the place you call. If the two are in the page, use the page. cache. in asax or your own function, use the latter
However, if you need to access an event, such as a timer-based processing function, because there is no httpcontext at the time, use httpruntime. Cache