Summary of differences between sessions and Cache in ASP. NET, asp. netsession

Source: Internet
Author: User

Summary of differences between sessions and Cache in ASP. NET, asp. netsession

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. Application is the information stored in the entire Application, 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.

Related Article

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.