4

If I were to use AppState variables as opposed to Session variables, I would not be storing data user-specifically. That is, if one user changes an AppState variable, it remains changed for all users on a site (it is application specific).

My question is, if I store values using the cache to transfer data between asp.net web-pages, is it user-specific or application specific? I always assumed it would be user-specific, however I read this:

The Cache is primarily intended to be used to improve performance of web pages, in that you can add any arbitrary object to it and retrieve it at will. Cache items are stored in memory on the server, and can be considered as special global variables.

(This is from: http://www.mikesdotnetting.com/Article/192/Transferring-Data-Between-ASP.NET-Web-Pages)

Knowing that the actual values are stored on the server, I began to wonder if the reference to these values are stored client side (like with Session variables) or if they are 100% stored server-side.

I would test this myself, but my work environment isn't really suitable for me to 'hop' on different machines very easily.

VoidKing
  • 6,282
  • 9
  • 49
  • 81
  • Presumably 100% serverside as there is no usercomponent.. (comparable to the old-school application object and not the session object) – AardVark71 Apr 02 '13 at 19:24
  • @AzardVark71 Thank you for the reply. I am beginning to feel very glad that I asked this question before attempting to transfer my 21 string variables along with my 9 12-index arrays across asp.net web-pages (and all for the sake of remembering form data through an OAuth request :S). – VoidKing Apr 02 '13 at 19:32

1 Answers1

3

The Cache is not user specific. It is similar to AppState, except that you can set expiration times on items in the Cache, and establish dependencies e.g. on a file or a SQL Server database (although you can't do that last part through the System.Web.Helpers.WebCache helper).

Mike Brind
  • 28,238
  • 6
  • 56
  • 88
  • Acutally, you can set the expiration time on items in the Cache through the WebCache helper. When you set the value (using WebCache.Set method : http://msdn.microsoft.com/en-us/library/system.web.helpers.webcache.set(v=vs.111).aspx) the third optional paramater is minutesToCache (default being 20 minutes) – AardVark71 Apr 03 '13 at 18:51
  • @AardVark71 Thanks - dunno how I managed to overlook that. I even covered it in my book. Amended my answer for accuracy. – Mike Brind Apr 03 '13 at 19:05