I developed a site in MODX Revolution 2.2.2-pl that updates the content every night with a php script. For each resource I have 5 images that are canceled recharged every night, very often happens that the texts and images remain mostly in the cache of modx and images in phpThumb cache.
How do I clear all cache completely every night?
If I empty manumalmente from the manager everything works but I try an automatic way that every night I empty the cache. On the net I found a scritp php cencellare the cache does not work.
It 'a very serious problem because every day I have to open the manager clear the cache.
-
☆ A M B ☆
- 1,780 Posts
If you can attach the snippet RefreshCache to a cronjob as well, you could clear the entire cache every night and then run refreshCache immediately afterwards. Although Lucas is correct, if you can selectively clear only the cache file necessary, that would be best.
Not sure how to activate RefreshCache in a cronjob. RefreshCache requires a click after viewing the resource to actually begin caching the site so you'd have to modify the snippet to automatically run itself I suspect.
http://bobsguides.com/refreshcache-tutorial.html
I think this would refresh just the Resource cache, which should be enough:
<?php
/* get all the Contexts */
$contexts = array();
$query = $this->xpdo->newQuery('modContext');
$query->select($this->xpdo->escape('key'));
if ($query->prepare() && $query->stmt->execute()) {
$contexts = $query->stmt->fetchAll(PDO::FETCH_COLUMN);
}
$results = array();
$modx->cacheManager->refresh(array(
'resource' => array('contexts' => array_diff($contexts, array('mgr'))),
), $results);
I am using cronJob Manager, but lets say now is 22:00 how to makeit every day at 02:00am??
<a href="www.play2web.com" title="izrada web sajtova">Izrada web sajtova</a>
-
☆ A M B ☆
- 1,780 Posts
Quote from: miomir.dancevic at Aug 11, 2016, 03:49 PMI am using cronJob Manager, but lets say now is 22:00 how to makeit every day at 02:00am??
Set the time to 02:00
22:00 is 10pm, therefore 2am is 02:00.