I use xFPC which speeds up my website nicely.
And I use Articles to publish blog posts.
I write blog posts in advance and use the Publish Date for when I want them published
So becuase I use xFPC the posts aren't getting published after the site is visited.
I have to clear the cache before the post shows.
So I thought I would set up a CRON job to call a page after the publish time so the blog post is set to published
then another to call a page that has a script that clears the cache so the pubished post will get cached
My problem: my script won't clear the cache
My script is this:
$modx->cacheManager->refresh(array(
'context_settings' => array('contexts' => array('web'))
));
I call the script uncached in a resource that is not cachable, and set xfpc.exclude so the resource won't get cached by xFPC
I thought maybe I'm missing something so I tried this script ( which I don't really understand, taken from
http://www.dangibbs.co.uk/journal/clear-modx-revolution-cache-from-php-script)
$modx->cacheManager->refresh();
// refresh the web context_settings partitions
$modx->cacheManager->refresh(array(
'context_settings' => array('contexts' => array('web'))
));
$contexts = array();
$query = $modx->newQuery('modContext');
$query->select($modx->escape('key'));
if($query->prepare() && $query->stmt->execute())
{
$contexts = $query->stmt->fetchAll(PDO::FETCH_COLUMN);
}
// refresh the default partitions in the default order, excluding the mgr Context
$results = array();
$modx->cacheManager->refresh(array(
'auto_publish' => array('contexts' => array_diff($contexts, array('mgr'))),
'system_settings' => array(),
'context_settings' => array('contexts' => $contexts),
'db' => array(),
'scripts' => array(),
'default' => array(),
'resource' => array('contexts' => array_diff($contexts, array('mgr'))),
'menu' => array(),
'action_map' => array(),
'lexicon_topics' => array()
), $results);
But to no avail I can't seem to clear the cache programmatically by calling a web page.
Has anyone got any suggestions?
Thanks
Mike