16.5 differences between session and Cache
In the past, there were many methods to cache data, including client cookies, Server sessions, and applications. Cookie is a set of data stored on the client, which is mainly used to save personal information such as the user name. Session stores the dialog information. The application is stored in the entire application.ProgramInformation within the range, which is equivalent to a global variable. Sessions are usually used most frequently. What is the difference between sessions and cache?
This section describes the differences between session cache and cache based on your experience.
(1) The biggest difference is that the cache provides a cache dependency to update data, and the session can only determine whether the cache data is valid Based on the defined cache time.
(2) even if the application is terminated, as long as the cache time defined in the cache. Add method does not expire, the cached data will still exist the next time the application is enabled. The session cache only exists in one session. After the session ends, the data becomes invalid.
(3) sessions are easy to lose, leading to data uncertainty, but the cache does not.
(4) because the session is loaded every time, it is not suitable for storing a large amount of information. Otherwise, the server performance will be reduced. The cache is mainly used to store large-capacity information, such as multiple tables in the database.
(5) the beta version of vs2005 provides parameters to save the cache on the hard disk. However, this function is canceled in the official version, and it is estimated that it will be implemented again in later versions. The session can only be stored in the memory, which affects its performance.