Interesting topic!
The first thing I look at is optimizing your database - even if you have to spend money on upgrading equipment, it will be much easier and cheaper than introducing into the cache - fewer moving parts, fewer things that can go wrong ...
If you cannot get more performance out of your database, the next thing I would consider is de-normalizing the data. For example, save the "reply_count" column rather than counting responses for each topic. This is ugly, but introduces fewer possibilities for things to go wrong - with little luck, you can localize all the logic at your data access level.
The next option I would consider is page caching. For example, just caching the “talk page” for 30 seconds should significantly reduce the load on your database, if you have reasonable levels of traffic, and even if everything goes wrong, because you are caching the whole page, it will sort itself into the next the time the page becomes obsolete. In most cases, caching the entire page in order is not the end of the world if a new record appeared in the last 30 seconds and you do not see it on your page.
If you really need to provide more “relevant” content on the page, you can enter caching at the database access level. In the past, I created a database access level that cached the results of SQL queries based on hard logic about how long to cache the results. In our case, we created a function to call the database, which allowed you to specify the request (for example, to receive messages for the user), an array of parameters (for example, username, date-time) and cache duration. The database access function will cache the results for the duration of the cache based on the query and parameters; if the cache expired, it will update the cache. This scheme was fairly error-resistant - as an end user, you rarely notice weirdness due to caching, and because we kept the cache period pretty short, it all sorted out very quickly.
Creating your page by caching pieces of content is possible, but very quickly becomes terribly difficult. It is very easy to create a page that makes no sense to the end user due to different caching policies - “unread messages” do not summarize the number of messages broken down due to different caching policies between “summary” and “summary” messages, detail. ”