We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26401
    • 247 Posts
    I’ve got a sendRedirect in a snippet that works fine in IE and FF, but not in 0pera.
    The snippet redirects to a login page if user is not a logged-in web user. Once the user is logged in the site redirects. In Opera however the page stays cached, so I want to send a header to tell it not to cache. Is there a way of doing that?

    This is only a problem with Opera as far as I’ve noticed, but then I haven’t tried all other browsers, and since it is an issue on one, it might be on others too.

    I solved it using
    header("Cache-Control: no-store, no-cache, must-revalidate");
    before the redirect call. But I will need to put it in other pages too, pretty much any non-static page.

    Anyhow, I thought I’d post this, although Opera is not the top browser choice for many, there are quite a few users, so check your pages, or if you have any other recommendations, please let me know.

    Maybe modifying the code that handles caching to include something like this might work.
      • 11155
      • 74 Posts
      What is your opera:config#UserPrefs|HistoryNavigationMode value ?
      Maybe you’re using a value that overrides the default behavior ? I’m using "3" for "Fast mode" but maybe you should set it to "2" for "Compatible mode" or "1" for "Automatic mode" ?
        • 38162
        • 97 Posts
        Probably a stupid question, but have you activated ’Enable automatic redirection’ in your Opera browser? Opera allows to easily disable redirection:
        Tools -> Preferences -> Advanced (tab) -> Network -> ’Enable automatic redirection’

          • 26401
          • 247 Posts
          I understand what you’re saying, but I can’t expect every Opera user to change their settings to view the site properly. It’s like moving the goalpost rather than the ball.
            • 11155
            • 74 Posts
            Except that "automatic redirection" is the *default* behaviour.
              • 38162
              • 97 Posts
              Quote from: GoustiFruit at Jan 21, 2010, 01:20 PM

              Except that "automatic redirection" is the *default* behaviour.

              Automatic redirection is indeed enabled by default. Just thought daspoda might have changed it a while ago and forgot to set it back.

              Btw, you can post a link to the site so I can check if it works for me. Opera is my main browser.
                • 26401
                • 247 Posts
                I’m thinking of not redirecting but posting a message that asks the user to log in.
                The headers will still need to be set, as I don’t want the users to have to hit refresh.

                I’ve been using opera for quite a while so it is possible that I changed something or something happened between the updates, but on Opera 10, the default setting shown for Always Check Redirect is not checked or off.

                I’ve worked a bit on the site since so it doesn’t redirect anymore.

                although somewhat off topic at this point here’s the snippet I’m calling from my template (in case anyone is interested)
                <?php
                // check if page requires user to be logged in
                $loginRequiredTV  = $modx->getTemplateVarOutput('LoginRequired');
                $loginRequired = strlen($loginRequiredTV["LoginRequired"]) > 0;
                
                $loginTemplate = isset($loginTemplate)? $loginTemplate : 'LoginRequiredTpl';
                
                if (!$loginRequired){
                	return "<!-- login not required -->\n[*content*]";
                }
                else{
                	header("Cache-Control: no-store, no-cache, must-revalidate");
                }
                // check if the user is logged in
                if (!isset($_SESSION['webInternalKey']) && !isset($_SESSION['mgrInternalKey'])) {	
                	return $modx->getChunk($loginTemplate);
                }else{
                	return "<!-- User logged in -->\n[*content*]";
                }
                ?>


                it uses a TV checkbox called LoginRequired (the login requirement check is a bit brute)
                this way all the pages that require a log in will be forced to refresh