We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36613
    • 328 Posts
    I search a external script for clear MODx revolution Cache. I have a script that import resurce from management system, when i finish of importing i want clear Cache and use this script:

    function clearMODxCache(&$modx) {
    // Clear the cache (taken from /core/model/modx/processors/system/clearcache.php)
    $paths = array(
    'config.cache.php',
    'sitePublishing.idx.php',
    'registry/mgr/workspace/',
    'lexicon/',
    );

    $contexts = $modx->getCollection('modContext');

    foreach ($contexts as $context) {
    $paths[] = $context->get('key') . '/';
    }

    $options = array(
    'publishing' => 1,
    'extensions' => array('.cache.php', '.msg.php', '.tpl.php'),
    );

    if ($modx->getOption('cache_db')) $options['objects'] = '*';

    // The final magic
    $results= $modx->cacheManager->clearCache($paths, $options);

    }

    but does not work.
      • 3749
      • 24,544 Posts
      You might try just this:

      $cm = $modx->getCacheManager();
      $cm->refresh();
      $modx->reloadContext('web');



      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting