GordonLesti / Lesti_Fpc

Simple Magento Fullpagecache
https://gordonlesti.com/lesti-fpc-documentationversion-1-4-5/
Other
358 stars 158 forks source link

Flush fpc cache #198

Closed dleone81 closed 8 years ago

dleone81 commented 8 years ago

Hi, I need to flush fpc cache via shell.

To do it I suppose to create a php file that contain this method and call it via cron or via shell when I need it

<?php require_once('app/Mage.php'); umask(0); Mage::app(); Mage::getSingleton('fpc/fpc')->clean()); ?>

but not works!

I can I do it? Thank you in advance

GordonLesti commented 8 years ago

Hello @dleone81 maybe it does not work, because of the last bracket.

dleone81 commented 8 years ago

Thank you for your comment (copy & paste error!) <?php require_once('app/Mage.php'); umask(0); Mage::app(); Mage::getSingleton('fpc/fpc')->clean(); ?>

The code not works! On frontend I've shop review widget. See this widget at bottom page here: http://www.magmodules.eu/index.php (what's client says)

When review is approved I can see it at all pages but the widget on frontend needs to update fpc cache via backend.

I need to schedule a cron task every hour to clean up all fpc cache but the scripts doesn't works.

Via shell I run: php myfile.php No errors shows up! But nothing happened If I try to update fpc cron via backend all works fine

Waiting your tips D

GordonLesti commented 8 years ago

Hello @dleone81 I'm not completely sure why your script doesn't work, but I have created my own one just to check. I have placed it in shell/fpc.php with the following content.

<?php

require_once 'abstract.php';

class Lesti_Fpc_Shell_Clean extends Mage_Shell_Abstract
{
    public function run()
    {
        Mage::getSingleton('fpc/fpc')->clean();
    }
}

$shell = new Lesti_Fpc_Shell_Clean();
$shell->run();

This works like expected, but I wouldn't recommend that just for reviews. Maybe it's better if we use the event review_save_after?

dleone81 commented 8 years ago

Hi Gordon, I've tried your script and works well!

I've added review_save_after to configuration > system > refresh_actions > review_save_after but my test fails!

Thank you in advance D

GordonLesti commented 8 years ago

review_save_after is a Magento event, not a Refresh Action.

dleone81 commented 8 years ago

I have to extend Magmodules_Shopreview or I can use Lesti_Fpc backend setting?

GordonLesti commented 8 years ago

No, I created a new issue for that https://github.com/GordonLesti/Lesti_Fpc/issues/199