开发者

What is the difference between (Caching) and [storing] variables in session?

开发者 https://www.devze.com 2023-02-07 16:33 出处:网络
What is the difference between (Caching) and [storing] variables in session开发者_JAVA百科???These are two different concepts with a different purpose (although their implementation may share some com

What is the difference between (Caching) and [storing] variables in session开发者_JAVA百科???


These are two different concepts with a different purpose (although their implementation may share some common infrastructure).

The purpose of caching is to improve performance, by eliminating the need for redundant server-side processing between requests. Caching can happen at the database level (e.g. by storing query results), the page level (by storing fully rendered HTML pages), or the page-component level (by storing HTML snippets). Caching can also be specific to the user and other parameters. An application that serves stock portfolios might cache its pages per user so that one user is not accidentally served another person's portfolio from the cache.

The purpose of session variables is to add state to web applications (the HTTP protocol is inherently stateless and there is no other way of keeping data around between requests).


If by caching you are specifically referring to the System.Web.Cache class, then the key difference between this and Session is that Cache is global to the application whereas Session is specific to a user.


Caching is a general term covering many possible implementations and options.

One such implementation is the Session variables in IIS, with the addition constraint of it being user specific (or user session specific, to be exact).

Others implementations can be the Application variables, browser cache, caching proxy servers, special caching software that sits between an application server and database and even CDNs (content delivery networks).

See the wikipedia article about cache.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号