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

    I'm trying to exclude a context and resources from clearcache function.
    I just want to remove files caches of a second context when I record resources.
    When I use the clearcache for main menu manager, I want to exclude second context from this function.

    Any idea ?

    Michel
      • 33968
      • 863 Posts
      You could create a custom 'Clear Cache' action something like this in the Handler field, and in the processor simply clear the cache for only the contexts you require:
      /* define a custom topic for your cache handler */
      var topic = '/customcache/';
      var register = 'mgr';
      if (this.console == null || this.console == undefined) {
          this.console = MODx.load({
          xtype: 'modx-console'
          ,register: register
          ,topic: topic
          ,show_filename: 0
          });
      } else {
          this.console.setRegister(register, topic);
      } 
      MODx.Ajax.request({
          /* define the path to your ajax connector */
          url: '/path/to/your/connector.php'
          ,params: {
              /* insert name of your action here */
              action: 'your/clearcache/action'
              ,register: register
              ,topic: topic
          }
          ,listeners: {
              'success':{fn:function() {
                  console.fireEvent('complete');
              },scope:this}
          }
      });
      this.console.show(Ext.getBody());
      return false;
      

      This is not copy and paste code, it's just to give you some idea of what to do. You might have to dig into the core code and have an idea how to create a custom action and CMP before doing this though, don't think there's any way to do it 'out of the box'.
        • 37927
        • 7 Posts
        I have a better solution, sorry ;-)

        It's consist to copy in a temporary directory content of directory context cache with a plugin on beforeEmptyCache event, and on CacheEmpty event, to recopy content of temp directory in initial directory.

        Two plugin without modify core.

        Thank you.
          • 33968
          • 863 Posts
          Creative smiley But what happens if you want to clear the whole site cache?

          Note also what I suggested is not a core modification but a custom action...
            • 37927
            • 7 Posts
            Yes, but I never want to clear cache for my second context.
            My client want to moderate resources. So I have separate content to be moderate and not to be in two context. I use the two version, database for moderation, cache for production. I have add a plugin on DocSave event, it send a mail when a editor has record a resource. Admin has just to go in manager and clear cache for the current resource when it's ok for him.