Browser caching on Joomla $mainframe->redirect

2019-06-03 23:39发布

问题:

I'm using a Joomla driven site and i'm having problems with Safari and the new Firefox caching redirects. Here's what I mean, a user comes to a page on my site which requires login, so I use $mainframe->redirect(loginpage) to redirect them to the login page, and also passing a $_GET variable of the page that the user was originally trying to visit.

After successful login, my script redirects back to the page which the user was trying to visit. In Chrome, this works fine, and it redirects with no problem. In Safari and the new Firefox, it caches the redirect so it doesn't redirect back to the original page after login, and stays on the login page. Even if I put the exact URL of the original page into the browser, it still redirects to the login page. It's only when I clear the browser cache, can I then access the original page.

Let me know if i'm not making sense, appreciate all the help I can get. Thanks

回答1:

I figured out the problem. Looks like some browsers cache 301 redirects, which is what Joomla was using in the $mainframe->redirect function. I have changed it to a 302 redirect and it is now working perfectly :-)



回答2:

We have seen the same problem your describing.

You must have an older version of joomla 1.5. We have 1.5.11 and its hardcoded to use 301. If you look at latest version of 1.5.23 on the official 1.5 api doc you will see that default is using 303 code. We are changing all our sites to use 303 redirects. 303 is supposed to tell the browser to always use a separate get to get the redirected page. Thank you for your post!