Storing an entire page's Contents in the Session

P

py

how feasible is it to cache an entire page's content in a session variable?
i am already doing it and it works fine, except i am afraid of scalability
issues. what is the best way to test this? and is there an obvious reason
why i should not do this.
 
J

Juan T. Llibre

Why would you need to do that ?
The Cache object will do that more efficiently.
 
P

py

i am simply storing a root level webcontrol that contains all of my page
controls. i believe cache object will purge itself when it runs low. plus,
i dont need to share the page with other sessions - it is just for the
session that is displaying it - i.e. one page per end user, so session level
is the right scope.

it saves asp engine from having to re-instantiate all the controls on each
request and maintains the data state (which i have programmed to time out on
its own)
 
T

Teemu Keiski

Depends what you have there, however if you store something like controls
there, you're shooting yourself to leg for good. All those resources are
tied to the lifetime of a session, and it would be multiplicated per-user
basis.

I'd look into Caching as Juan hinted, depending on your case either data
caching with cache object or outout caching (caching the rendered content)
when you could avoid non-needed caching or cache only the necessary
resource-intensive part.
 
T

Teemu Keiski

it saves asp engine from having to re-instantiate all the controls on each
request and maintains the data state (which i have programmed to time out
on its own)

Believe me, Framework is optimized this in mind, classes including controls
are instantiated very fast, as they are compiled code etc. and instances odf
compiled page classes are cached after JIT'ing.

Another drawback with your approach is that Controls are not serializable.
This works as long as you have sessions in InProc (in-process) mode, however
if you need to switch to state server or SQL server for better reliability
(to stand app/process restarts), it won't work and you're on your own with
it.
 
R

recoil

The Viewstate very often already does this in most cases. You should
probably elaborate on what exactly you are trying to do.
 
K

Kevin Spencer

As a general rule, caching UI components is a bad idea. Cache is best used
for pure data.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
P

py

ok - sounds like sound advice.

another related question:
how much data is reasonable to cache? i am using subclassed datatables as
my data source. when should i worry about memory consumption?

(i am embarassed to admit i dont know how to test for this)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top