Login caching in the header

Hi,

Cache plugin: LiteSpeed Cache

Steps to reproduce:

  1. Go to the homepage.
  2. Click on “Login” in the header.
  3. Log in successfully.
  4. Go to the Jobs/Ads page.
  5. 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?

Thanks

Hi,

If you use a caching plugin, make sure that caching is disabled for logged-in users.

Hope it helps

Good afternoon, thank you for your reply.

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?

Please disable third-party plugins and customizations (if there are any) and let me know if this issue persists.

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’ll add that if you refresh the homepage, the user’s name appears instead of “Login”

While we can’t provide support for third-party plugins, please check this topic to find a snippet for disabling caching for logged-in users [How to add custom code snippets - HivePress Help Center]:

Hope this helps

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?

Hi @narobotu,

Which theme are you using?

Cheers,
Chris :victory_hand:

Hi :slightly_smiling_face:,
JobHive

Hi,

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.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.