DEV Community

Yassin Alm
Yassin Alm

Posted on

How do you cache User Profiles with dynamic "Follow" buttons?

The Scenario I’m building Postly, a blogging platform using Spring Boot 3. To make profile loading fast, I want to cache the UserProfile object in Redis.

The Issue The profile page has a "Follow/Unfollow" button.

If User A views the profile, it says "Follow".

If User B (who already follows them) views the same profile, it says "Following".

If I cache the whole Profile DTO in Redis, I risk showing the wrong button state to the wrong user.

Top comments (0)