Login button takes me to my profile page
-
I just closed the browser, opened it again, clicked login… And my profile page opened, but the top bar didn't change at all. The UI only changed its state after I hit Shift+F5.
Has anyone else experiences that issue before?
-
@asdf Sounds like the browser loaded from cache instead of loading fresh
-
@RaceProUK Yeah, but even if the page was cached it should still reconnect to the server, verify your session, and figure out that you are/aren't logged in.
Discourse did something similarly annoying... every time I opened my browser, the cached page thought I was still logged in and never figured out that I wasn't until a refresh. Although it was perfectly happy to throw up error messages as soon as I tried to interact with the page in a way that was restricted to logged-in users ("like" something, reply).
Although... if he was still logged in, I don't know why the cached page would have thought that he was not.
-
@RaceProUK said:
Sounds like the browser loaded from cache instead of loading fresh
Initially? Definitely not, since I was shown as logged out and had been logged in before I closed the browser window.
-
This post is deleted!
-
@asdf With SPAs, the browser cache doesn't necessarily reflect the most current state of the webpage
-
@RaceProUK True, but the application must make sure that the browser cache doesn't get in its way. If it doesn't, that's a bug in the application, since it's sending incorrect cache control headers.
-
@asdf In SPAs, the content updating is done via AJAX, and there's no way to manipulate the browser cache from JavaScript, so it's not possible for the app to refresh the cache
-
@RaceProUK You don't need to manipulate the cache, you just need to update the page in realtime.
-
@RaceProUK said:
In SPAs, the content updating is done via AJAX, and there's no way to manipulate the browser cache from JavaScript, so it's not possible for the app to refresh the cache
But initially, the page should reload, right? Or request the current state from the server?
Either there's a server-side bug (allowing the browser to cache something it shouldn't cache) or there's a client-side bug (UI not updated appropriately after making the AJAX calls). Either way, it's a bug.
-
@anotherusername said:
You don't need to manipulate the cache, you just need to update the page in realtime.
That's not enough; I know from experience
-
@RaceProUK it is enough. You detect that the interface is showing a login button when the server says that you're already logged in, or vice versa... you update the interface to match what the server says. Or you just force the whole page to refresh.
-
@anotherusername Oh, you mean in a
$(window).on('popstate', fn);
sort of way? That's the solution I use :)
-
@RaceProUK Well, I was thinking of pageshow, but that would probably work too.
But even if you wait for the user to actually start interacting with the page, at some point there should be code that says "hey the server's saying we're not logged in anymore but we're still showing that we are; we should probably trigger a refresh".