Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From my general understanding I believe UserContext for a web application is supposed to hold user authentication and authorization (user roles) information.

As part of user roles, there are definitions on who can access what data and accordingly the corresponding reference data is loaded into the UserContext as well.

Is this a good practice to load and use reference data from UserContext? Does this have any impact with the number of sessions vs size of data it is holding inside JVM?

I am thinking we use UserContext only for authentication and authorization but load the reference data from cache on demand and use it if required.

share|improve this question

This is always a trade off of how much space you're taking up in the session. How big is your reference data? Generally speaking, unless it's small I'd use the caching approach you described.

DOn't forget that user sessions can be shared across clusters etc as well, so generally speaking keeping them small is a good thing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.