Part III, state management and caching
What is state management, beginning for the web, after the previous section of the explanation, has been understood, for the Web program, is a stateless program, each request and each response, the two itself is independent, which for the early static Web page, it is nothing, Because each request and response is actually fixed. However, in the era of Dynamic Web pages, it is not, a large part of web development work will become state management. This, perhaps, for example, the most representative, such as a shopping cart, then for the shopping cart, you need to know who his visitors are? Although they can be switched on different pages, the shopping cart cannot change, and this is a state management.
(More state-managed scenarios, you can add)
Chapter 14th Session State
Session is a conversation state, unified browser after a period of time to access the server, will produce a 24-bit unique SessionID, this ID identifies the identity of the client, although customers can switch between different pages, but SessionID are unchanged.
Session usage, the session is the internal property of the page class, and then directly using the Key/value mode directly.
The session is divided into two types: server and Client
Server: Meaning the session defines the storage location of the variables that need to be cached, which can be stored in the process, the proprietary servers, the database
Client: means that the storage location of SessionID can be used to make cookies or URLs (to resolve non-cookie-supported browsers)
The <sessionState></sessionState> section in WEB.CONFG is used to complete the settings for this section.
The type of data that the session can store, except for the simple data type, all of the types that can be serialized are stored by the customer.
Description: The page class built-in objects, there are application,session,cache,request,response, and so on, usually many people use Application,session,cache as a data cache, in fact, they are different.
Application, which is used as a global variable in the process, is the life cycle of the application. The more it takes up more memory.
Session, in fact, it is not only to access a variable, he stores a session of the variable, and he will have sessionid to distinguish between the client, session storage variables is only one of his indirect implementation function. And he can exist in a process, a database, or a dedicated server.
The cache, he is stored in the process, the life cycle is can be set, he has more flexible properties, including expiration time, expiration notice, etc., he is to complete the cache processing of complex objects.
Chapter 15th caching of Application data
The cache object is introduced, using a method similar to the session to improve the access of complex variables. Improve the performance of Web Access.
16th output Cache
At the beginning of the time, really did not specifically understand what is called the output cache, and later looked at the original is called the page cache, different books, the name may be different. Why is there a page cache? The essential goal is to improve the performance of Web Access, do not repeat the calculation of Web pages, reduce the pressure on the server, improve the performance of the Web application, so from the angle of the data cache, generated the cache, from the angle of the page output buffer, is the page generated, put in a place, Each request is then returned directly to the page.
Usage: is to use <% @outputcache > instructions on each page header, attributes include cycles, dependencies, and so on.
Description: Personally, only from having Ajax, the meaning of output cache is reduced, because it can be partially refreshed, the concept of the output of the entire page is not big.