Results 1 to 14 of 14

Thread: page cache and login/logout links

  1. #1
    User
    Join Date
    06-20-09.
    Posts
    64

    Default page cache and login/logout links

    Hi
    I have a block with the 2 links - login/register (custom html) and logout(automatic logout).

    With settings: login/register - "show only for guest" and logout- "only for register users"

    The issue is - once user logged in and redirected to the last page visited or main - this blocks get cached, so user still sees login/register links.

    I'm able to get right data only after the force cache refresh by ctrl+F5.


    I've tried to disable cache for this page - set cache timeout to 0, but seems that this is very bad solution, and really strange that I'm not able to use build-in caching.


    Could someone give me a hint, how to build proper caching for this behaviour.
    Thank you in advance

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: page cache and login/logout links

    Isn't a ctrl+F5 on your own system? Contao should always send server cached file (when caching enabled) and that way ctrl+F5 doesn't refresh and change that. What I mean to say is that I can't tell if the problem is in Contao or in your browser.

  3. #3
    User
    Join Date
    06-20-09.
    Posts
    64

    Default Re: page cache and login/logout links

    I press ctrl+f5 to refresh cache on my browser.
    I looked on this process in Chrome dev tools, and it says that page was from cache.

    I'm not saying that this is contao issue, or I just setup something in a wrong way. My assumption that:
    after user successfully logged in - contao redirects user to the previous page, it must send some headers (no-cache, must-revalidate) to force browser refresh that page.

    I'm not able to reproduce this with logout, because it sent 303 see other header.

  4. #4
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: page cache and login/logout links

    Hmm, that is a hard one. Does the browser refresh if you had redirected to another page and then went to the first page?

    Just saying something that comes to mind; how would the browser handle variables or anchors in the url? It would definitely refresh to at least the first, right? Perhaps there is a way to add that to the url...

  5. #5
    User
    Join Date
    06-20-09.
    Posts
    64

    Default Re: page cache and login/logout links

    I've tried to add something like /#logged on redirect - still the same.

  6. #6

    Default Re: page cache and login/logout links

    Contao do not serve from the cache once you are logged in! Which version Contao are you using?
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  7. #7
    User
    Join Date
    06-20-09.
    Posts
    64

    Default Re: page cache and login/logout links

    Hi, I'm using 2.10.3

  8. #8
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: page cache and login/logout links

    What about redirecting to a page with a random ?variable=4a8f11 attached. Come to think of it; I don't know how to do that easily...

  9. #9

    Default Re: page cache and login/logout links

    I tried it on Contao 2.10.3 as you have described.
    1. Enabled the cache for all pages
    2. Login module only for guests (Redirect to last page visited)
    3. Logout link protected( only for login members).

    It worked as expected. When I logged in, I see logout link and Login is now hidden. Since you have mentioned Chrome dev tools, I have tested in both Chrome and FF, it worked.

    The issue is - once user logged in and redirected to the last page visited or main - this blocks get cached, so user still sees login/register links.
    Do you see then (automatic logout) link too? Or did you change/patched anything in core.
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  10. #10
    User
    Join Date
    06-20-09.
    Posts
    64

    Default Re: page cache and login/logout links

    I don't have login module. I have links login/logout which is just a html module.
    the whole process looks like

    main page -> click on login link -> redirect to the page with login form -> login->redirect to main page.

    I haven't touched the core.

  11. #11

    Default Re: page cache and login/logout links

    So again I tired as you might have done.
    - On main page (home), I placed 4 new content elements (CE).
    1) A CE of text with Link to login page (show only to guest)
    2) A CE of type HTML with some content (show only to guest)
    3) A CE of type module Custom Html one, again (show only to guest, in CE setting)
    4) A CE of type module Custom Html two (protected, in CE setting)

    Made sure the page is cached before login -> Clicked the link to login page -> Logged in there, got redirected to main page (home).
    As expected content element 1,2,3 is gone and CE 4 is now visible. Are we doing the same thing.
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  12. #12
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: page cache and login/logout links

    Both login and logout redirect using the same function and also both send "HTTP/1.1 303 See Other". So that is identical. As you already say the page is cached, but tsarma doesn't seem to have the problem. Perhaps we need to see if this is an isolated problem on your machine/server/contao installation.

    Can you test this on a different computer, with more then one browsers by recreating your setup on the contao demo? At least then we know the setup is correct and we also eliminate your pc specific settings. This should help in finding the problem and the solution.

  13. #13
    User
    Join Date
    06-20-09.
    Posts
    64

    Default Re: page cache and login/logout links

    Thank you Tsarma and Ruud.
    I'm going to test this on my local machine (this evening if I'm lucky). + I'm going to test this with another hosting provider.

  14. #14
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: page cache and login/logout links

    I doubt it to be your hosting provider, you'd probably best test that last.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •