I have a theoretical question with applications to it.
Imagine an internet application where, on a page you have to show all instances of some object. You can get them from a database and show them.
But then, when the user wants to visit that same page again, or see detailed information on one of the objects in another page, should you load it again (going to the database again) or should you save what you previously loaded inside a session and show it again?
What if the loading of the objects is not as fast as a local database, and you have to get those objects over http from another server in an XML form?
Are there any clear guidelines or conventions about this?
If speed really is an issue or you’re likely to experience a high server load, you probably want to cache the data locally.
How often you update the cache would largely depend on how often objects change in the database. If they change very often, caching is likely to be a bad idea as your probably going to be presenting your users with out-of-date information.