We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Calling cacheManager->refresh() with no arguments will delete almost all of the cache files (but takes some time). It can be called with arguments to selectively delete parts of the cache.

    I'm not sure about reloadContext(). I think it just refreshes the resource map for that context. I don't believe it affects the cache at all. It's a fairly fast way of getting MODX to recognize a newly created resource -- the OP's original problem.

    No MODX function that I know of deletes *all* the cache files. There is an extra called CacheClear that does. It's faster because it does no permission checks and simple unlinks everything in the cache directory. I think you could install it and just add this to your code:

    $modx->runSnippet('CacheClear');


    Remember that the next visitors to your site will see a slowdown because the cache is empty. One of the reasons cacheManager->refresh() takes so long is that it recreates some of the cache files.
      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
      • 53932
      • 33 Posts
      Quote from: BobRay at Jan 04, 2018, 07:54 PM
      Calling cacheManager->refresh() with no arguments will delete almost all of the cache files (but takes some time). It can be called with arguments to selectively delete parts of the cache.

      I'm not sure about reloadContext(). I think it just refreshes the resource map for that context. I don't believe it affects the cache at all. It's a fairly fast way of getting MODX to recognize a newly created resource -- the OP's original problem.

      No MODX function that I know of deletes *all* the cache files. There is an extra called CacheClear that does. It's faster because it does no permission checks and simple unlinks everything in the cache directory. I think you could install it and just add this to your code:

      $modx->runSnippet('CacheClear');


      Remember that the next visitors to your site will see a slowdown because the cache is empty. One of the reasons cacheManager->refresh() takes so long is that it recreates some of the cache files.

      Thanks for the details. I'm using reloadContext() in my code and i'm glad that it wouldn't effect the the cache at all (to avoid slow down of site). you are correct that reloadContext() only refreshes the resource map for that context. I also verified with my script.

      Thanks Bob for the quick response and the clarification.