Craft CMS Asked by Joorren on May 5, 2021
I’m having a problem with navigation that seems to get cached.
If the page is loaded by someone who is not logged in, it shows the login button in the navigation (and it should).
Once the user is logged in and returns to that specific page (by clicking a link on the site), the page still shows the login button.
Only when the user manually refreshes the page, the login button gets replaced by the users name.
The template code uses the currentUser variable, which is never overwritten anywhere else.
There’s no cache blocks used on the website, and the cache-control header is set to no-store, no-cache, must-revalidate
{% if currentUser %}
{% if currentUser.firstName != '' and currentUser.lastName != '' %}
{{ currentUser.firstName }} {{ currentUser.lastName }}
{% else %}
{{ currentUser.email }}
{% endif %}
{% else %}
{{ loginPage.title }}
{% endif %}
It turns out the cache-control headers weren't coming through at the end.
I solved the problem by adding all the right headers.
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 12 Jan 1980 05:00:00 GMT"
Correct answer by Joorren on May 5, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP