Zend_Controller_Action_Helper_Cache

classic Classic list List threaded Threaded
4 messages Options
krl
Reply | Threaded
Open this post in threaded view
|

Zend_Controller_Action_Helper_Cache

krl
Hi

I have difficulties in making the Zend_Controller_Action_Helper_Cache function as it should.
I created an example project using zf.sh script and then did the necessary modifications as described here: http://framework.zend.com/issues/browse/ZF-9148?focusedCommentId=38409&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38409

I also changed the owner of the cache directories.

Here's what my IndexController.php looks like:

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
        $this->_helper->cache(array('index'), array('all'));

    }

    public function indexAction()
    {
        // action body
    }

    public function removeAction()
    {
        $this->_helper->getHelper('Cache')->removePagesTagged(array('all'));
    }

}

The problem is that public/cached/index.html file is created but it's empty.
I also tried the Zfplanet project where Zend_Controller_Action_Helper_Cache is used as well and there it worked fine, the cache file was not empty.

What might be wrong or missing in my project?

Best regards and thank you in advance
KRL
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Controller_Action_Helper_Cache

padraicb
Page and Static caching each have an additional requirement that output buffering is disabled in the Controller stack. It interferes with what we're trying to do (capture output). I'm clueless as to why the Controller even has output buffering (maybe someone could explain?) but it needs to be disabled for the static cache to operate properly. The Reference Guide for both the static and page caches contains a note explaining which setting to change. It's the most common error leading to empty cache files.

Paddy
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative



From: krl <[hidden email]>
To: [hidden email]
Sent: Sat, May 29, 2010 1:24:03 PM
Subject: [fw-general] Zend_Controller_Action_Helper_Cache


Hi

I have difficulties in making the Zend_Controller_Action_Helper_Cache
function as it should.
I created an example project using zf.sh script and then did the necessary
modifications as described here:
http://framework.zend.com/issues/browse/ZF-9148?focusedCommentId=38409&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38409

I also changed the owner of the cache directories.

Here's what my IndexController.php looks like:

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
        $this->_helper->cache(array('index'), array('all'));

    }

    public function indexAction()
    {
        // action body
    }

    public function removeAction()
    {
        $this->_helper->getHelper('Cache')->removePagesTagged(array('all'));
    }

}

The problem is that public/cached/index.html file is created but it's empty.
I also tried the Zfplanet project where Zend_Controller_Action_Helper_Cache
is used as well and there it worked fine, the cache file was not empty.

What might be wrong or missing in my project?

Best regards and thank you in advance
KRL
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Zend-Controller-Action-Helper-Cache-tp2235633p2235633.html
Sent from the Zend Framework mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Controller_Action_Helper_Cache

holografix
Hi
I posted a question about this in April but still have the problem.

My virtual host configuration looks like this:
<Location />
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ /index.php [NC,L]


    # cache rules
    RewriteCond %{REQUEST_METHOD} GET
    RewriteCond %{DOCUMENT_ROOT}/cached/index.html -f
    RewriteRule ^/*$ cached/index.html [L]

    RewriteCond %{REQUEST_METHOD} GET
    RewriteCond %{DOCUMENT_ROOT}/cached/%{REQUEST_URI}\.html -f
    RewriteRule .* cached/%{REQUEST_URI}\.html [L]
</Location>

This creates the html files in the cache folder but I guess it does'n bypass php.
A rough benchmark with apache ab gives about 20 reqs/sec and there is no .htaccess present.

If I remove the "cache rules" from httpd.conf and put them in an .htaccess file, ab benchmark reports about 500 reqs/sec.

Using apache and php 5.3.2 cgi, Windows 7 x86  without apc. I clean the files in cache folder and restart apache after httpd.conf/.htaccess changes.

Cheers
holo

2010/5/29 Pádraic Brady <[hidden email]>
Page and Static caching each have an additional requirement that output buffering is disabled in the Controller stack. It interferes with what we're trying to do (capture output). I'm clueless as to why the Controller even has output buffering (maybe someone could explain?) but it needs to be disabled for the static cache to operate properly. The Reference Guide for both the static and page caches contains a note explaining which setting to change. It's the most common error leading to empty cache files.

Paddy
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative



From: krl <[hidden email]>
To: [hidden email]
Sent: Sat, May 29, 2010 1:24:03 PM
Subject: [fw-general] Zend_Controller_Action_Helper_Cache


Hi

I have difficulties in making the Zend_Controller_Action_Helper_Cache
function as it should.
I created an example project using zf.sh script and then did the necessary
modifications as described here:
http://framework.zend.com/issues/browse/ZF-9148?focusedCommentId=38409&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38409

I also changed the owner of the cache directories.

Here's what my IndexController.php looks like:

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
        $this->_helper->cache(array('index'), array('all'));

    }

    public function indexAction()
    {
        // action body
    }

    public function removeAction()
    {
        $this->_helper->getHelper('Cache')->removePagesTagged(array('all'));
    }

}

The problem is that public/cached/index.html file is created but it's empty.
I also tried the Zfplanet project where Zend_Controller_Action_Helper_Cache
is used as well and there it worked fine, the cache file was not empty.

What might be wrong or missing in my project?

Best regards and thank you in advance
KRL
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Zend-Controller-Action-Helper-Cache-tp2235633p2235633.html
Sent from the Zend Framework mailing list archive at Nabble.com.

krl
Reply | Threaded
Open this post in threaded view
|

Re: Zend_Controller_Action_Helper_Cache

krl
In reply to this post by padraicb
Hi

Thank you. I added the following line to my application/configs/application.ini file:
resources.frontController.params.disableOutputBuffering = true
and the cache files are not empty any more. However I only got it working in my main project, not in the project described in my first email that I created for testing the cache. Nevertheless I can now continue with my main project.

Best regards
KRL

Pádraic Brady wrote:
Page and Static caching each have an additional requirement that output buffering is disabled in the Controller stack. It interferes with what we're trying to do (capture output). I'm clueless as to why the Controller even has output buffering (maybe someone could explain?) but it needs to be disabled for the static cache to operate properly. The Reference Guide for both the static and page caches contains a note explaining which setting to change. It's the most common error leading to empty cache files.

Paddy
 
Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
OpenID Europe Foundation Irish Representative



From: krl [hidden email]
To: [hidden email]
Sent: Sat, May 29, 2010 1:24:03 PM
Subject: [fw-general] Zend_Controller_Action_Helper_Cache


Hi

I have difficulties in making the Zend_Controller_Action_Helper_Cache
function as it should.
I created an example project using zf.sh script and then did the necessary
modifications as described here:
http://framework.zend.com/issues/browse/ZF-9148?focusedCommentId=38409&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_38409

I also changed the owner of the cache directories.

Here's what my IndexController.php looks like:

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
        $this->_helper->cache(array('index'), array('all'));

    }

    public function indexAction()
    {
        // action body
    }

    public function removeAction()
    {
        $this->_helper->getHelper('Cache')->removePagesTagged(array('all'));
    }

}

The problem is that public/cached/index.html file is created but it's empty.
I also tried the Zfplanet project where Zend_Controller_Action_Helper_Cache
is used as well and there it worked fine, the cache file was not empty.

What might be wrong or missing in my project?

Best regards and thank you in advance
KRL
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Zend-Controller-Action-Helper-Cache-tp2235633p2235633.html
Sent from the Zend Framework mailing list archive at Nabble.com.