Asp. NET in the session and cache difference Summary _ practical skills

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.