The implementation method and principle of. NET page cache. The page output cache is the simplest cache format. The output cache is reserved as a response in the memory.
Html
When there is another request, the cache output will be provided until the cache expires. The rational use of cache may greatly improve the website performance, depending on the overhead required to create the original page output-
Sending, cache output is always fast and stable .. NET page cache implementation methods and principles are briefly introduced as follows:
I. ASPX page Cache
The usage of page cache is very simple. You only need to add a statement <% @ outputcache duration = "60" varybyparam = "NONE" %> at the top of the ASPX page.
Duration = "60" indicates that the cache time is 60 seconds, you can set varybyparam = "NONE" as needed, which means to set the cache with no parameters (the cache with parameters will be discussed below)
The implementation method and principle of. NET page cache. These two parameters are required and cannot be default. Another important parameter, diskcacheable = "True | false", indicates whether to place the cache on the hard disk. If it is set to false, the cached data is stored in the memory.
Note that if the page data is small, the cached data can be stored in the memory. If the data is large, it is best to put it on the hard disk. Otherwise, it will occupy a large amount of memory and affect the running of the server, if the data is cached to the hard disk
If the value of duration = "" is set to a greater value, for example, duration = "3600". If the value is too small, if the server writes data on the hard disk too frequently, the performance will be reduced.
Yes. If you cache data duration in the memory, you should not set it too long. Of course, the specific length of time requires you to try more.
Ii. Disable IE caching
If there is a page New. aspx, after the first access by the client, it will have
New. aspx. After the file is generated, if the data of New. aspx is modified and accessed again, ie does not update the data of New. aspx.
This is the first page to be accessed!
. NET page cache implementation method and principle, ie automatically (by default) calls the Internet Temporary Folder has a new. instead of downloading the New. aspx, how can I enable IE to automatically download the new one. aspx, Just Like clicking the refresh button to reload the page
Solution 1:
Client setting method: Internet Options → General → "Settings" in Temporary Internet Files → check each time you access this page.
It is best to delete temporary files at the same time in this setting. This method allows the customer to set their own browsers. If the customer forgets the setting, the new page will not always be downloaded locally. what do customers think? ("It must be a program error! ") In addition, when someone else accesses your page, the client browser will operate on them. Generally, this method is not suitable for solving such problems.
Solution 2:
Let the program automatically download the page! In this way, the page is not saved to the Temporary Internet folder. Every time you access the page, the browser downloads the page .. NET page cache implementation method and principle, as long as you add
Context. response. cache. setcacheability (httpcacheability. nocache.
When this sentence is not added, open the page. There will be a page file in the Temporary Internet folder. If this sentence is added, it will disappear. However, if an image or JS file exists in An ASPX file, it will still be downloaded to a temporary Internet folder.
3. Disable page caching when the showmodaldialog () function in JS opens the ASPX page
. NET page cache implementation method and principle, method 1: first write an htm page, nested in an iframe, iframe src is the aspx page, then ShowModalDialog () this is the htm page instead of the previous aspx page, so there is no cache problem.
Method 2: Write Response. expires =-1 in Page_load () of the aspx page, which means that the page will expire immediately, so that no htm page is nested outside.
The implementation methods and principles of. NET page cache are described as above. The cache mechanism of ASP. NET allows WEB applications to frequently access data.
Data, and the data that requires a lot of system resources and time to be created is stored when the program is run for the first time. When the page is accessed next time, the program does not need to consume resources to create data, and can directly retrieve data from the storage,
This greatly improves the overall performance of the program.
Original article address:
Http://www.lx9d.com/page/20110102180221.html