(on Wednesday, 13 May 2009, 04:14 AM -0700):
> Peculiar issue/feature, can't seem to find anyone else with any info about
> it.
>
> Everytime a request is made to the site when using Zend_Layout, it appears
> that the request is run twice. I noticed this when using sessions to store
> response messages to the user that are removed from the session once they
> are displayed. I could never get these messages to display, but after some
> investigation and logging to file found out that the request is run twice.
> Putting a simple log message in the a bootstrap file will log the message
> twice, with every request made to the framework. I confirmed this by
> profiling the database queries also.
Traditionally when I've seen people complain of this, one of two things
are happening (and they're, in the end, the same thing):
* They don't have a favicon.ico for the site.
* There is a reference to an image, CSS file, or JS file that does
not actually exist on the site.
In both situations, the browser requests the page, and then requests the
given resource. Since the resource was not found, it falls back to your
MVC application -- and hence the apparent "second request".
The solution? Make sure you have a favicon.ico file, even if it's empty,
and that any resource your layout or application defines in the markup
actually exists on the server.
> I thought that perhaps this was something I had done so did a fresh install
> as per instructions here: http://framework.zend.com/docs/quickstart and the
> boot strap file is still being called twice.
>
> This is a bit concerning as every request to the server seems to be
> processed by the server twice before returning a response. You should be
> able to replicate this by following the instructions in the quickstart
> tutorial, stop once you've added the layout, then add a
> put_file_contents("/tmp/file", "Message\n", FILE_APPEND) in the
> _initDocType() method in the bootstrap class. One browser request will
> result in two lines in the file /tmp/file ???
>
> Can someone tell me why this is and if there is anyway to prevent this from
> happening? It seems a little crazy that by adding a layout we need to
> process everything twice.
>
> Running:
> PHP 5.2.6
> Apache 2.2.9
> Zend Framework 1.8
> Only modifications to the Quickstart tutorial is added a line to log to file
> each request.
--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论