We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45063
    • 40 Posts
    I'm using domaineer plugin for showing different content on different domains, but alongside, I'm using another context for different language. The problem is, that when I switch the contexts by http_host detection, I am loosing domaineer placeholders (they parsed in json array). Everything fine when I am using this construction of gateway plugin on each case statement:

    $modx->switchContext('web');
    $modx-$modx->cacheManager->refresh();
    


    And the same goes for each context. But, as you can guess, Its a huge performance impact. Can I somehow var_dump cache for each domain? Because, as I can see, refresh() runs on every appearance of http_host. E.g, even when a single link on the same domain is clicked.
      • 45063
      • 40 Posts
      So, here is the solution:

      In a gateway plugin we don't need to refresh all the cache partitions. Instead, we need to refresh only resource cache of all domains pointing to web context because its much more faster:

      $modx->cacheManager->refresh(array(    
          'context_settings' => array('contexts' => $contexts),    
          'resource' => array('contexts' => array_diff($contexts, array('mgr')))    
      ), $results);


      After that, install the microcache plugin by opengeek via Plugin Manager: http://modx.com/extras/package/microcache

      And finally, comment out those lines in microcache plugin itself for plugin to work on your main content:

      /* do not cache if the cacheable content still contains unprocessed tags */
                  //$matches = array();
                  //if ((($isAnonymous && !empty($skipIfTagsRemainAnonymous)) || (!$isAnonymous && !empty($skipIfTagsRemain))) && $modx->parser->collectElementTags($modx->resource->_content, $matches)) break;


      Now everything is smooth and shiny. 4 partially different sites in one context + 1 different language site on another context working fast without any bugs.