We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44843 ☆ A M B ☆
    • 10 Posts
    markwillis82 Reply #1, 13 years ago
    Hello,

    When using the managers "Clear Cache" function, it doesn't clear all the entries in the APC cache (mainly the context keys and a few others) so what happens is - when we move a resource to a new area (so the url updates) the cache doesn't get emptied and the new url does not work until we manually clear APC (which we have to do server wide at the moment)

    Is there a better way to clear every element from the APC cache?

    Thanks
      • 10208 ☆ A M B ☆
      • 1,780 Posts
      One of your best friends with MODX will be easy access to the core/cache folder. Simply delete all the files in core/cache to clear the full cache. You could even delete the core/cache folder, as it will regenerate as soon as you load a page or refresh the manager. Although removing the files inside are plenty to do the job.

      Bob Ray has an Extra to do this within the manager, although access via the server's file manager or FTP also does the job. I've been using Bob's snippet on the last few sites I've worked on and as always, it does the job nicely and conveniently.

      http://modx.com/extras/package/cacheclear
      http://bobsguides.com/cache-clear-tutorial.html

      I gotta admit, I've never understood the nuances between the manager's cache clear and a full delete of the core/cache files, but doing so is your first go to when issues arise. I'm relying on this snippet more and more lately. FTP is so incredibly slow, forget that. Logging into the control panel on a server makes for fast cache clears but who wants to do that every time?

      Yeah, try CacheClear.


        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 22303 MODX Staff
        • 10,725 Posts
        Unfortunately, APC caching does not store entries in files within the core/cache/ folder, so manually clearing that folder will not help when using cache.xPDOAPCCache as your cache_handler.

        @markwillis82 — Can you share how you have your MODX cache settings configured, including any related System/Context Settings as well as any $config_options from your config file (in core/config/)?
          • 44843 ☆ A M B ☆
          • 10 Posts
          markwillis82 Reply #4, 13 years ago
          I have setup the core/config file with these settings:

          $config_options = array (
            'cache_handler' => 'cache.xPDOApcCache',
            'cache_db' => true,
            'cache_db_prefix' => 'dom',
            'cache_resource_key' => 'dom1',
            'cache_prefix' => 'dom1'
          );


          And these following system settings:

          cache_handler: cache.xPDOApcCache
          cache_prefix: dom2
          cache_resource_key: dom2
          cache_db_prefix: dom2

          (I've replace my key names with dom)

          I also have cache_db set to false
            • 22303 MODX Staff
            • 10,725 Posts
            First, it should be cache.xPDOAPCCache.

            Also, why are you changing the cache_resource_key and adding cache_prefix and cache_db_prefix? I think you should remove these unless you have a specific purpose for changing them.

            Finally, you say cache_db is false (I assume in System Settings), but you have cache_db set to true in the config _options.
              • 40385
              • 75 Posts
              Bump!

              I am having the same problem. Changes are never coming through unless a clean the apc cache server-wide which is a huge performance drawback. Here are my settings in the main config:

              $config_options = array (
              "cache_prefix" => "flox_",
              "cache_handler" => "cache.xPDOAPCCache",
              );

              The cache_prefix is set because I am having multiple MODx installations using APC cache (which is server-wide) and I don't want to see content mixed or messed up between the different MODx installations.

              Any idea on how I can get changes reflected in frontend without having to delete the apc cache server-wide?
                • 40385
                • 75 Posts
                Additional debugging:

                public function flush($options= array()) {
                        $flushed = false;
                        if (class_exists('APCIterator', true) && $this->getOption('flush_by_key', $options, true) && !empty($this->key)) {
                            $iterator = new APCIterator('user', '/^' . str_replace('/', '\/', $this->key) . '\//', APC_ITER_KEY);
                            if ($iterator) {
                                $flushed = apc_delete($iterator);
                            }
                        } else {
                            $flushed = apc_clear_cache('user');
                        }
                        return $flushed;
                    }


                Afaik this part $flushed = apc_clear_cache('user'); is crucial for clearing the cache but when using debugging messages while clearing the cache this part is never fired meaning the cache gets never deleted successfully. Any ideas?