There are many ways to implement data caching in the past, with client cookies, server-side sessions, and application. A cookie is a set of data that is stored on the client and is used primarily to hold personal information such as user names. Session saves the dialog information. Application is the information stored throughout the application, which is equivalent to a global variable. Usually the most frequently used is the session, then the session and cache what is the difference?
This section provides a detailed introduction to the difference between the session cache and the cache cache in conjunction with experience.
(1) The biggest difference is that the cache provides caching dependencies to update the data, and session can only rely on the defined cache time to determine whether the cached data is valid.
(2) Even if the application terminates, the cached data still exists the next time the application is opened, as long as the cache time defined in the Cache.Add method does not expire. The session cache only exists in one session, and the data is invalidated after the conversation has ended.
(3) session is easy to lose, resulting in the uncertainty of the data, and cache does not appear this situation.
(4) because the session is loaded each time, it is not appropriate to store a large amount of information, otherwise it will result in lower performance of the server. And cache is mainly used to save large capacity information, such as multiple tables in the database.
(5) The beta version of VS2005 provides the parameters for saving the cache on the hard disk, but this feature is canceled in the official edition and is expected to be implemented again in later versions. The session can only be saved in memory and has an impact on its performance.