I have looked around for common patterns for caching where you aim for speed via page caching but also want to render and display user session-specific data (i.e. username, shopping cart, etc.). So far I’ve found an approach from 2015 that calls for caching the rendered page without the user-specific content and then caching an updated version with the user-specific content so end-users can still benefit from a mostly publicly cached view. I have also seen other recommends for using an AJAX request as an alternative where you publicly cache the page like normal and then update the user-specific elements via JS.
Both solutions are great and would certainly work with only a few tradeoffs but I was wondering if there are newer approaches that might be preferable for one reason or another? The AJAX approach adds a little delay due to the extra request per pageview for instance and the two-pass caching still increases the size of your cache.
Any thoughts on the topic are appreciated. Thanks!