Reputation: 28545
Im using asp.net mvc 3.
Im implementing a points system similar to SO. I want to show the users points on every page. should i store this in a session variable?
or can i use outputcache on a partial action to show it on every page? i dont want to make a dbcall just for this on every page.
im a little reluctan with session variable, i hear too many mixed comments about them
thanks
Upvotes: 0
Views: 847
Reputation: 73102
I wouldn't store it in session.
If the user does something that affects their points, you'll have to update the session each time. Use session for things that change rarely during a user's time on your website (like their username, preferences, etc).
Don't forget, what if someone "upvotes" something the user has done - how would you know about this unless you call the db?
I would use regular Cache
, possibly with a SqlCacheDependency
on the table which contains the user rep, so when it changes it invalidates the cached data.
Upvotes: 1