We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47725
    • 4 Posts
    Hello everyone,

    I am working on a cache on save plugin with the use of the OnDocFormSave event. Now I noticed that when I let it rebuild the cache by going to the URI with CURL after it has cached everything it needs to the /core/cache/resource folder gets emptied. Is there something I'm doing wrong or do I need to use a different event because it maybe clears the cache right after the OnDocFormSave event instead of before?

    Code example:
    $events = array('OnDocFormSave');
    $eventName = $modx->event->name;
    
    if (in_array($eventName, $events)) { 
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $modx->getOption('site_url') . $resource->uri);
        curl_setopt($ch, CURLOPT_FAILONERROR,1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 15);
        $retValue = curl_exec($ch); 
        curl_close($ch);
    }
    return true;
    


    Thanks in advance,

    Robin Rijkeboer

    This question has been answered by BobRay. See the first response.

    [ed. note: beagon last edited this post 12 years, 3 months ago.]
    • discuss.answer
      • 3749
      • 24,544 Posts
      You might look at the CacheMaster extra. It may do what you want. If it doesn't, you may find the code helpful.
        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
        • 47725
        • 4 Posts
        Quote from: BobRay at Jun 19, 2014, 05:48 PM
        You might look at the CacheMaster extra. It may do what you want. If it doesn't, you may find the code helpful.

        Thank you bob, that indeed was helpful, it was not where I was looking for but I found what I did wrong because of your CacheMaster extra. I forgot that every file had a Clear Cache on Save checkbox which would remove my cached files. Thanks to your plugin I know how to resolve that! Thank you again!
          • 3749
          • 24,544 Posts
          I'm glad I could help. 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