Tuesday, July 2, 2013

Re: 301 infinite redirect

Hi AD,

after one complete day of debug/experiment without success, I noticed that attribute Age: 0 appears at the second Server Response of the loop.

Searching for the specification of the Age header field, I suspect the presence of the header field Age: 0 maybe means that the response is sent by intermediate cache from the server.

So I added in the send() function on lib/Network/CakeResponse.php (I know it's probably a bad idea, but it's only for discover the problem) this:

if ($this->_status === 301) {
           $this->_sendHeader("Cache-Control: no-store, private, no-cache, must-revalidate");
           $this->_sendHeader("Cache-Control: pre-check=0, post-check=0, max-age=0, max-stale = 0");
}

And now the server response after redirect is 200 and everything works well.

My question now is: Is it a cake problem or a server problem?

My doubt came for this reason: In local always works fine. But on online server, with a only PHP file with the same headers that CakePHP set for a redirect, any loop is created and there's no need to disable browser cache. Only happens if the headers are set inside CakePHP code.

Albert


El dilluns 1 de juliol de 2013 21:36:54 UTC+2, AD7six va escriure:


On Monday, 1 July 2013 20:57:04 UTC+2, floydbrush wrote:
Sorry, I tried to explain but my "spanish" english is bad :/

What I wanted yo say is that not exists that information, seems like is not executed redirect in the loop.

If there's no log entry for Cake redirecting from /testredirected/test to /testredirected/test, but your app IS redirecting like that - then either:

1) Your app isn't responsible for that redirect
2) Your app is responsible for the redirect but the thing responsible isn't using the controller redirect method.

You need to identify how that redirect is being issued, the first step to that is reproducing the problem which so far you're only doing indirectly (not going to help/work). That means, quite simply, you need to debug/experiment. Put stuff like this in your webroot/index.php:

<?php
if ($_GET['url'] === '/testredirected/test') {
    echo "Forcing a  headers-already-sent error";
}
...

And look at the stack trace when your app issues a redirect.

That's just an example - you need to do the leg work to find your logical loop.

AD

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: