In the header, click again to return to the homepage.
On the homepage, in the header, the user field shows “Login” again as if I’m not logged in. If I click it, a login modal appears. However, if I click on another page in the header, e.g. Jobs, then in the header my username is displayed correctly.
It looks like the issue is with caching: on the homepage the cache is shown as if the user is not logged in.
Has anyone dealt with a similar issue or can suggest how to prevent the login element in the header from being cached?
Not exactly - in the case described above, with caching disabled for logged-in users, it still doesn’t display correctly. For example, if you go to the site’s homepage, then to another page (like “Information”), log in there, and then return to the homepage — the same issue occurs, even with caching disabled.
As I understand it, in this case the homepage is cached when visiting the site. Then, after logging in and going back to the homepage, the page is still served from cache, and in the header it shows that the user is not logged in, even though they actually are.
Is there any way to make sure that the login element in the header is never cached and is always displayed in real time — both for logged-in and logged-out users?
If LiteSpeed Cache is disabled, everything works without any issues.
It’s also strange that the problem does not occur in the admin area, it only occurs for a regular logged-in user.
I tried the code above, also completely disabled the caching plugin and others, but the problem still persists. Could the issue be with AJAX, where the header is not being re-rendered after login? Or could it be due to caching in the browser itself?
If the issue persists with the LiteSpeed plugin disabled, this is most likely caused by the hosting-side caching. Please reach out to the hosting provider to clarify this, as there are no caching functions within HivePress that may prevent header HTML from refreshing on login.