Re: RequestHandler::isAjax() buggy?
On Sun, Nov 28, 2010 at 10:57 PM, Dr. Loboto wrote: > Check that request is really done. I never saw this in anything except > IE, but in IE it is always aggressive caching when browser do not > repeat request to the same URL in the short period of time at all. If > you see same (no real request) in other browsers it is definitely > aggressive caching by headers of your app or your web server. What's weird is i was seeing it in 3 separate browsers. I didn't check IE because I was stressed enough without having to boot Windows, as well (it kind of always gives me the creeps :-) That's why i assumed it must be server-side. Unfortunately, my stress level made me jump to conclusions about isAjax(). (And, yes, I'm pretty embarrassed about that) So I next wondered about Apache. Except nothing's been changed there recently. In the end, the bug disappeared. I was making repeated requests with Firebug's Net tab open. Nothing. A Heisenbug, perhaps. I don't know what I might have done to fix the problem. I did dump the cache, but I was seeing the problem after that. Then ... no more bug. I hate that, because I don't know if/when it's going to appear again. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: RequestHandler::isAjax() buggy?
Hi, maytbe this will halp you to find your bug. I have add into app_controller before_filter() this lines $this->disableCache(); I've found this solution in http://osdir.com/ml/CakePHP/2010-01/msg00629.html (for view this link content - look into google cache, now it forbidden for me :( ) On Nov 29, 5:57 am, "Dr. Loboto" wrote: > Check that request is really done. I never saw this in anything except > IE, but in IE it is always aggressive caching when browser do not > repeat request to the same URL in the short period of time at all. If > you see same (no real request) in other browsers it is definitely > aggressive caching by headers of your app or your web server. > > On 29 ноя, 02:34, cricket wrote: > > > On Sun, Nov 28, 2010 at 2:56 PM, cricket wrote: > > > I'm seeing some strange behavior on a site. I haven't been able to > > > reproduce it locally, just on the server, and it's also only showing > > > up just once in a while. What's happening is, occasionally, isAjax() > > > is incorrectly returning true, and so just the element is rendered. > > > > public function index() > > > { > > > $this->Session->write('path_back', $this->here); > > > > $this->set('data', $this->paginate()); > > > > if ($this->RequestHandler->isAjax()) > > > { > > > $this->viewPath = 'elements'.DS.'books'; > > > $this->render('pagination'); > > > } > > > } > > > > So, I've got a paginated list of books, and I'm loading further pages > > > using AJAX. The session business allows me to get back to the correct > > > index page from a "view" view. I can't think of any reason why that > > > would be involved, though. > > > > I can't remember seeing anyone else report this sort of thing. Has > > > anyone run into it? Or have any suggestions for why this might be > > > occurring? Or how to go about debugging this? > > > Sorry for the noise. This fell into my lap while I was busily trying > > to get something else to deadline and I wasn't thinking things through > > very well. It's not a Cake issue, although I'll continue here as it > > might be of help to someone someday. > > > The obvious first step is to log the request headers before rendering > > just the element. I did that and see: > > > [X-Requested-With] => XMLHttpRequest > > > So Cake is doing the right thing. Next step: check the browser. I was > > using FF 3.6.12. I could see that the page is being refreshed but > > tried disabling JS anyway. Sure enough, I was able to eventually > > repeat it. I then opened the site in Chrome (7.0.517.44) and clicked > > away for a while (remember, this bug only shows up occasionally). I > > was literally just about to give up on Chrome when the bug showed > > itself. I then was able to get Opera (10.10) to do it. > > > I disabled caching, on the principle that it couldn't hurt, so why > > not? No difference. > > > Speaking of caching: Firefox is showing this un-styled rendered > > element, and I try shift-refresh. After four or five tries, the page > > finally loads correctly. WTF? This makes no sense at all. > > > Maybe an Apache bug? That's beginning to seem like the only > > explanation. Especially as everything's fine locally. Will update that > > and post results. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: RequestHandler::isAjax() buggy?
Check that request is really done. I never saw this in anything except IE, but in IE it is always aggressive caching when browser do not repeat request to the same URL in the short period of time at all. If you see same (no real request) in other browsers it is definitely aggressive caching by headers of your app or your web server. On 29 ноя, 02:34, cricket wrote: > On Sun, Nov 28, 2010 at 2:56 PM, cricket wrote: > > I'm seeing some strange behavior on a site. I haven't been able to > > reproduce it locally, just on the server, and it's also only showing > > up just once in a while. What's happening is, occasionally, isAjax() > > is incorrectly returning true, and so just the element is rendered. > > > public function index() > > { > > $this->Session->write('path_back', $this->here); > > > $this->set('data', $this->paginate()); > > > if ($this->RequestHandler->isAjax()) > > { > > $this->viewPath = 'elements'.DS.'books'; > > $this->render('pagination'); > > } > > } > > > So, I've got a paginated list of books, and I'm loading further pages > > using AJAX. The session business allows me to get back to the correct > > index page from a "view" view. I can't think of any reason why that > > would be involved, though. > > > I can't remember seeing anyone else report this sort of thing. Has > > anyone run into it? Or have any suggestions for why this might be > > occurring? Or how to go about debugging this? > > Sorry for the noise. This fell into my lap while I was busily trying > to get something else to deadline and I wasn't thinking things through > very well. It's not a Cake issue, although I'll continue here as it > might be of help to someone someday. > > The obvious first step is to log the request headers before rendering > just the element. I did that and see: > > [X-Requested-With] => XMLHttpRequest > > So Cake is doing the right thing. Next step: check the browser. I was > using FF 3.6.12. I could see that the page is being refreshed but > tried disabling JS anyway. Sure enough, I was able to eventually > repeat it. I then opened the site in Chrome (7.0.517.44) and clicked > away for a while (remember, this bug only shows up occasionally). I > was literally just about to give up on Chrome when the bug showed > itself. I then was able to get Opera (10.10) to do it. > > I disabled caching, on the principle that it couldn't hurt, so why > not? No difference. > > Speaking of caching: Firefox is showing this un-styled rendered > element, and I try shift-refresh. After four or five tries, the page > finally loads correctly. WTF? This makes no sense at all. > > Maybe an Apache bug? That's beginning to seem like the only > explanation. Especially as everything's fine locally. Will update that > and post results. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: RequestHandler::isAjax() buggy?
On Sun, Nov 28, 2010 at 2:56 PM, cricket wrote: > I'm seeing some strange behavior on a site. I haven't been able to > reproduce it locally, just on the server, and it's also only showing > up just once in a while. What's happening is, occasionally, isAjax() > is incorrectly returning true, and so just the element is rendered. > > public function index() > { > $this->Session->write('path_back', $this->here); > > $this->set('data', $this->paginate()); > > if ($this->RequestHandler->isAjax()) > { > $this->viewPath = 'elements'.DS.'books'; > $this->render('pagination'); > } > } > > So, I've got a paginated list of books, and I'm loading further pages > using AJAX. The session business allows me to get back to the correct > index page from a "view" view. I can't think of any reason why that > would be involved, though. > > I can't remember seeing anyone else report this sort of thing. Has > anyone run into it? Or have any suggestions for why this might be > occurring? Or how to go about debugging this? Sorry for the noise. This fell into my lap while I was busily trying to get something else to deadline and I wasn't thinking things through very well. It's not a Cake issue, although I'll continue here as it might be of help to someone someday. The obvious first step is to log the request headers before rendering just the element. I did that and see: [X-Requested-With] => XMLHttpRequest So Cake is doing the right thing. Next step: check the browser. I was using FF 3.6.12. I could see that the page is being refreshed but tried disabling JS anyway. Sure enough, I was able to eventually repeat it. I then opened the site in Chrome (7.0.517.44) and clicked away for a while (remember, this bug only shows up occasionally). I was literally just about to give up on Chrome when the bug showed itself. I then was able to get Opera (10.10) to do it. I disabled caching, on the principle that it couldn't hurt, so why not? No difference. Speaking of caching: Firefox is showing this un-styled rendered element, and I try shift-refresh. After four or five tries, the page finally loads correctly. WTF? This makes no sense at all. Maybe an Apache bug? That's beginning to seem like the only explanation. Especially as everything's fine locally. Will update that and post results. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: RequestHandler::isAjax() buggy?
The function is extremely simple: function isAjax() { return env('HTTP_X_REQUESTED_WITH') === "XMLHttpRequest"; } That's the standard way of checking for an ajax request. In regards to debugging I'd suggest throwing in some logs, both $_SERVER and when a successful ajax was accomplished. Track down the timestamp and cross reference what request is coming across as ajax when it shouldn't. Hope that helps, Nick On Nov 28, 12:56 pm, cricket wrote: > I'm seeing some strange behavior on a site. I haven't been able to > reproduce it locally, just on the server, and it's also only showing > up just once in a while. What's happening is, occasionally, isAjax() > is incorrectly returning true, and so just the element is rendered. > > public function index() > { > $this->Session->write('path_back', $this->here); > > $this->set('data', $this->paginate()); > > if ($this->RequestHandler->isAjax()) > { > $this->viewPath = 'elements'.DS.'books'; > $this->render('pagination'); > } > > } > > So, I've got a paginated list of books, and I'm loading further pages > using AJAX. The session business allows me to get back to the correct > index page from a "view" view. I can't think of any reason why that > would be involved, though. > > I can't remember seeing anyone else report this sort of thing. Has > anyone run into it? Or have any suggestions for why this might be > occurring? Or how to go about debugging this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
RequestHandler::isAjax() buggy?
I'm seeing some strange behavior on a site. I haven't been able to reproduce it locally, just on the server, and it's also only showing up just once in a while. What's happening is, occasionally, isAjax() is incorrectly returning true, and so just the element is rendered. public function index() { $this->Session->write('path_back', $this->here); $this->set('data', $this->paginate()); if ($this->RequestHandler->isAjax()) { $this->viewPath = 'elements'.DS.'books'; $this->render('pagination'); } } So, I've got a paginated list of books, and I'm loading further pages using AJAX. The session business allows me to get back to the correct index page from a "view" view. I can't think of any reason why that would be involved, though. I can't remember seeing anyone else report this sort of thing. Has anyone run into it? Or have any suggestions for why this might be occurring? Or how to go about debugging this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en