I have been searching online for a long time and found many of them are invalid. Can I only use <% @ outputcache %> to set the page cache? Finally, I found what I wanted in ASP. NET 3.5 decryption.
Add the following in the page_load event on the page:Code:
Protected void page_load (Object sender, eventargs E)
{
Response. cache. setcacheability (httpcacheability. Public );
Response. cache. setexpires (datetime. Now. addseconds (15 ));
// Response. cache. setmaxage (timespan. fromseconds (15); // This sentence is optional. It only determines when the client opens the page and sends a request to the server.
Response. cache. setvaliduntilexpires (true); // This sentence is required. Its function is to ignore the header Pragma: No-cache in the client request information, and the Application Server Page Cache
// Response. cache. setlastmodified (datetime. Now); // if this sentence is not required, the server cannot return the 304 status code.
// Response. cache. setomitvarystar (true); // do not use this sentence
Response. Write (datetime. Now. tostring ());
}