In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how ASP.NET caches pages. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Cache page
Use the OutputCache instruction
Duration and VaryByParam features are required.
VaryByParam allows us to cache different versions of the page. In the above example, VaryByParam is set to RequestID, so ASP.NET uses different values of the RequestID parameter, which are passed either in the query string of HTTP GET or in the parameter of HTTP POST. Applications can be made to distinguish between different users by checking the value of the RequestID parameter; by placing VaryByParam= "RequestID" in the page's OutputCache directive, you can have ASP.NET cache different versions of the page for each user.
If you don't want to cache the unasked version of the page based on the value of the parameter, just set VaryByParam to none.
You can also ask ASP.NET to cache a version of the page for each possible parameter combination. To do this, set VaryByParam to *.
The VaryByHeader and VaryByCustom features are similar to VaryByParam in that they allow you to specify when a new cached version of the page should be created.
VaryByHeader allows us to cache the non-directional version of the page at the end of the list of HTTP headers separated by semicolons.
When VaryByCustom is set to browser, it allows us to cache different versions based on the browser's name and major version information. You can also set it to the name of a custom method to implement our own logic and control the cached version.
Fragment cache
You can use the user control to segment the page and write cached statements in the ascx file instead of in the aspx file, so that ASP.NET can cache only the output of the ascx fragments. Generally speaking, headers or footers are basically the same, so there is no need to reload. However, if there is dynamic data in it, it cannot be cached, because once cached, the program will no longer create its instance to update the data display, only until the lifetime expires. So page fragment caching is not suitable for this case.
Note:
Note that fragment caching does not support the Location feature; the only legal place for caching page fragments is the web server. This is because fragment caching is a new feature in ASP.NET, so browsers and proxy servers do not support it.
Second, fragment caching has another feature that is not available in the page cache-VaryByControl. The VaryByControl feature allows you to specify a semicolon-delimited list of strings representing the names of the controls used within the user control; ASP.NET generates a cached version of the user widget for each different combination of values.
Data caching
The low-level API is the Cache class, which is located in the System.web.Caching namespace in ASP.NET and can be used to cache and generate resource-intensive data. The use of the Cache class is as simple as Session and Application objects. There is only one Cache object per application-- this means that the data stored in the cache using Cache objects is application-level data. To make things easier, the Cache property of the Page class enables the application's Cache object instance to be used in the code.
Data cached through the Cache object is stored in the application's memory. This means that the lifetime of this data will not exceed the restart of the application (in fact, this is the same as data stored in Application and Session objects, unless Session data is stored in StateService or SQL State session mode).
The specific use and syntax are the same as Session and Application. When you convert it back, you need to pay attention to the corresponding type casting.
This is not the only way to add cached items to the ASP.NET cache. The Cache object has two methods, the Insert () method and the Add () method, which are more flexible. Their usage is similar, but slightly different:
The Insert () method is used to overwrite existing cache items in the ASP.NET cache.
The Add () method is only used to add a new cache entry to the ASP.NET cache (it will fail if you overwrite an existing cache item with it).
Each method has seven parameters, and the parameters of both methods are the same.
When caching an item, you can specify its dependency, telling the ASP.NET cache page to remain in the cache until an event occurs.
Thank you for reading! This is the end of the article on "how ASP.NET caches the page". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.