Not sure why it would cache this value, as usually the user-like info is complete gone when you log out.
I'd verify the cache settings on all elements, template, page, Web Part
both - 1. Performance > Partial cache minutes - 2. System settings > Cache minutes), Site Settings.
You could have a look at the Caching debugging (Settings > System > Debug > Cache access).
Alternatively it might be a good idea to move this whole logic to a custom macro. Might be a bit more work to setup, but gives a lot more flexibility and control. As well as making it easier to reuse on other places.
docs.xperience.io/k11/.../registering-custom-macro-methods