We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 577
    • 132 Posts
    Maybe BobRay has put this out to the world but I have not run across it anywhere.

    I am tired of battling both cache issues and [[!Include? ...]] tags for local development. Things are constantly cached when I don't want them to be and cache_disabled does not actually work in the core.

    CacheClear to the rescue.


    1. Download and install CacheClear
    2. Create Plugin
    3. Copy code below into plugin
    4. Set System Event to "OnWebPageComplete"
    5. Set System Setting cache_disabled = to Yes

    Now on the completion of every page request the cache is dumped

    <?php
    if ($modx->context->key == 'mgr') return;
    
        if((boolean) $modx->getOption('cache_disabled',null,false)){
        $modx->runSnippet('CacheClear');
        }
    


    Now we can go back to using static elements in local dev without having to clear cache all the time. smiley
      "One of these days I will get around to my own website... Its only been about 12 years... maybe tomorrow smiley"
      • 3749
      • 24,544 Posts
      Interesting idea. Thanks for posting it. smiley

      Do you mind if I make a blog post out of it? wink



        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
        • 577
        • 132 Posts
        Not at all , please do.
          "One of these days I will get around to my own website... Its only been about 12 years... maybe tomorrow smiley"
          • 3749
          • 24,544 Posts
          Thanks. BTW, I think that should be $modx->context->get('key'). wink

          Love your sig. I just changed the references to MODx to MODX on my site's home page. smiley
            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
            • 577
            • 132 Posts
            If you are using this setup and also developing in Manager Only areas then you will want to make the following adjustments

            Add additional System Event to plugin

            "OnManagerPageInit" <!-- this will flush the cache on every manager request

            Also comment this out of the plugin

            //if ($modx->context->key == 'mgr') return;
            
              "One of these days I will get around to my own website... Its only been about 12 years... maybe tomorrow smiley"