That solely depends on what the scope of the data is. If it is application scoped data, then you need it to put in an application scoped bean in any way.
Mohammed Amine Tazi
Joined: Feb 09, 2009
In fact, I'm wondering if it's a best practice to load a catalog of products in an application scope JSF managed bean from startup, or to use caching after the first call of a product.
And is it possible to update cache using setter methods in the managed bean.
There's nothing wrong with using caching in either application or session scope for a performance boost (providing you have the spare memory!). In point of fact, I have a number of apps that get menu definitions from a database at app startup, cache them, and use the cache to render menus. In most cases, these menus are static, although it's fairly simple to add a cache update command to the app.
I've used this strategy both in JSF and in Struts for years.
One thing to bear in mind, however, is that if you're using an ORM, the ORM framework is probably maintaining its own cache. So depending on circumstances, you might not see the big speed boost you're hoping for, and in fact could potentially see a small slowdown from the overhead of caching data that's in the ORM cache, so plan accordingly.
An IDE is no substitute for an Intelligent Developer.