0

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 %}
1
  • 1
    Have you verified in DevTools of your Browser, that the page really get the no-cache header? To me this sounds like a browser caching issue. Also try set the Expiry time in your .htaccess (or other server config) to 0 for HTML like this (only works with mod_expires on Apache): ExpiresActive on ExpiresByType text/html "access plus 0 seconds" Jan 25 at 19:38
0

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"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.