Database object or page cacheing?
I’ve found in practice (in common with a lot of other people) that database object cacheing like Hibernate’s 2nd level object and query caches are not that useful in general for my applications (it’s still too low level) and can complicate matters. I really want to cache higher level output, such as entire blocks of page content and let pages be rebuilt from the db without intervening db caches.
If your cache supports tagging, an interesting idea for web page cacheing is to work out which db objects a page depends on, and apply id tags to the cached page for those objects. When any of those db objects are updated, an interceptor can automatically expire tagged content from the page cache.
So for example, a page that depends on Article id 3445 and Message id 3938 in schema db is cached with tags [“db.Article.3445”, “db.Message.3938”].
The page builder generates the cache key and these tags, and any others such as generic labels like “content.latest” which can be used for periodic expiry of large numbers of cached articles which are tagged with that tag.