The first is to use ASP's built-in cache, which stores object data in memory Second, if in Mvc in the controller or code block use [OutputCache(Duration = 100)] Third If it's an http request [WebMethod(CacheDuration=60)] Fourth, if using webform in the code block, add [System.Web.UI.PartialCaching(120)]
If the amount of data is relatively small, it can be used 1.sessino <input id="HiddenValue" type="hidden" value="Initial Value" runat="server" NAME="HiddenValue"> ViewData ViewState["Country"] cookies Query String
Of course, what are the benefits of using caching? 1. Performance, which can reduce the repeated creation, processing, and transmission of data, and cache the data without change, which can significantly improve the response speed of the web program; 2. Stability If the number of users on the same page is too large, if each request is processed, it will consume a great waste of resources and cause system instability 3. Availability Sometimes, some services that improve data are stopped, and at this time there is a cache, and the user continues to use it, which improves the availability of the system
|