Title: MultiNetwork compatibility?
Last modified: January 13, 2024

---

# MultiNetwork compatibility?

 *  Resolved [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/)
 * I’m switching from Redis Object Cache, mainly because of the compatibility issues
   with WP Multi Network. I have several sub-networks that have to be maintained
   separately, but since the ROC plugin can have only one object cache, I had all
   kinds of wierd behavior. The object cache on the main network did not seem shared
   with other sub-networks, as I assign more blogs to sub-networks and keep less
   blogs in the main network. The metric got decreased to nearly zero, which I guess
   means there is nothing to cache for. i.e. sub-network contents were not object
   cached.
 * For Docket Cache, I’ve tested it for a few hours, and it seems like, whether 
   I activate the plugin in sub-networks or not, the main network cache is working.
   The sub-network’s cache disk is nearly fixed at small amount (20~30M), while 
   the main network’s cach disk goes with 200~400M on average. I believe the sub-
   network’s 20~30M is only for the sub-network’s main site.
 * I set the cache disk limit to 2G for all main- and sub-networks, and also used
   your code to create RAM cache (not sure if it worked though, because it looks
   like to create only 1 RAM disk). I have a dedicated server with plenty of hardware
   resources so it is no big deal, as long as the cache works.
 * I wonder if what I see is normal, or if I have to change any settings for sub-
   networks. My ideal case is separate cache for each sub-network, and each can 
   have separate RAM disk.
 * After a few hours, I already have cache files as ‘199000 / 200000’ for the main
   network. One way to handle it is, I guess, to increase the limit in your code,
   but this won’t help me to create multiple object cache files for each sub-network.
 * Overall, the idea seems great in that object cache files are created in PHP format,
   which is the fastest possible option for PHP servers, and w/ RAM disk option,
   if all PHP converted object/op cache files are stored in RAM disk, it isn’t that
   different from Redis. In comparison to PHP-Redis, I do not feel that much difference,
   though this ‘feeling’ should be verified reasonable benchmarks. But, as long 
   as it works with my multi-network, I have no reason to go back to Redis.

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/multinetwork-compatibility/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/multinetwork-compatibility/page/2/?output_format=md)

 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17339929)
 * Just so you know, the cache path and config path are set differently for each
   sub-network. Just wonder why then it does not create cache files for each sub-
   network. Either I missed something, or it does not work?
 *  Plugin Author [Nawawi Jamili](https://wordpress.org/support/users/nawawijamili/)
 * (@nawawijamili)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17340946)
 * Hi there,
 * Thank you for using Docket Cache and asking a question about Multi-Network.
 * For Multi-Network, the cache path for the main network will use the default `
   wp-content/cache/docket-cache`.
 * For sub-networks, Docket Cache will create and store a cache in `wp-content/cache/
   docket-cache/network-(n)`.
 * `(n)` indicates for network Id, if your sub-network Id is `2`. Docket Cache will
   create the cache path as `wp-content/cache/docket-cache/network-2` and store 
   a cache in it.
 * > My ideal case is separate cache for each sub-network, and each can have separate
   > RAM disk.
 * To use a different [ramdisk](https://docs.docketcache.com/faq#what-is-a-ram-disk-in-docket-cache)
   you need to mount a different cache directory.
 *     ```wp-block-code
       mount -t tmpfs -o size=2G tmpfs ./cache/docket-cache-2
       ```
   
 * The current version cannot change the sub-networks cache path, it will always
   be created in `wp-content/cache/docket-cache`.
 * You may download the dev version here [https://docketcache.com/devtest/docket-cache-230802-rc2.zip](https://docketcache.com/devtest/docket-cache-230802-rc2.zip)
   and define the `DOCKET_CACHE_PATH_NETWORK_2` constant in the `wp-config.php` 
   file.
 * Change 2 with your sub-network Id.
 * For example:
 *     ```wp-block-code
       define('DOCKET_CACHE_PATH_NETWORK_2', '/home/site/wp-content/cache/docket-cache-2');
       ```
   
 * For security reasons, Docket Cache will create ‘network-2’ directory and will
   be `/home/site/wp-content/cache/docket-cache-2/network-2`
 * > Just wonder why then it does not create cache files for each sub-network. Either
   > I missed something, or it does not work?
 * If the cache path is created and has a cache file on it, it works. Otherwise,
   either a write permission issue or there is no object cache to store.
 * Thanks.
 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17342800)
 * Thx for sharing the rc version. [@nawawijamili](https://wordpress.org/support/users/nawawijamili/)
 * I think I pretty much followed what you mentioned, but it does not seem sub-network’s
   create ‘Object Cache’ that in overview, I see Object Cache ‘Not Available’.
 * In ./cache/docket-cache-x/network-x folder, I can see that there are some files,
   but again, not sure if Object cache is really working. Zend OPcache seems working
   fine that in overview I can see ‘123M emory of 3642 files’.
 * Just to confirm my steps,
    - added ‘define(‘DOCKET_CACHE_PATH_NETWORK_x’, ‘/var/www/superadmin.giai.org/
      wp-content/cache/docket-cache-x’);’ to wp-config.php
    - in ./wp-content/cache folder, I do have /docket-cache-x
    - I have activated docket cache plugin in sub-network’s admin network
    - mounted the folder to ram disk
 *  -  This reply was modified 2 years, 4 months ago by [Keith](https://wordpress.org/support/users/keithkhl/).
 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17342824)
 * It seems like there is little bit of confusion in folder structure. For each 
   sub-network, should I go with /docket-cache/network-x or /docket-cache-x/network-
   x?
 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17342862)
 * I also have following errors in .object-cache.log file
 * [2024-01-13 03:26:23 UTC] err : “000000000000-000000000000” “cache_get: Class“
   WC_Subscription” not found.” “”
   [2024-01-13 03:26:23 UTC] err : “000000000000-
   000000000000” “cache_get: Class “WC_Order” not found.” “”
 * Woocommerce is activated only in one of the subsites, and all the other sites
   are connected to that one via web hooks, in case you wonder about my settings.
 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17342865)
 * For flushing cache files, I have ‘sorry you do not have permission’ error.
 * This happened to main network’s admin site.
 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17342873)
 * For the main network, in the overview
    - cache path: /wp-content/cache/docket-cache
    - config path: /wp-content/docket-cache-data
 * For the sub-network, in the overview
    - cache path: /wp-content/cache/docket-cache-x/network-x
    - config path: /wp-content/cache/docket-cache-x/network-x
 * But in WP folders, I can see folder structure like
    - wp-content/docket-cache-data
    - wp-content/docket-cache-data/network-3
 * and in cache folder
    - /wp-content/cache/docket-cache
    - /wp-content/cache/docket-cache/network-3
    - /wp-conent/cache/docket-cache-3
    - /wp-content/cache/docket-cache-3/network-3
 * Not sure what’s going on exactly, but I feel like cache path/config path must
   be reset for the sub-network, so as the cache folder structure, given what I 
   hae in wp-content/docket-cache-data
 * Besides, since the RC update, the performance got slower about 50~80%. For example,
   for the most heavy website’s admin page, it used to take 5 secs to reload the
   edit.php page, which was nearly the same as Redis Object Cache, but w/ RC + aforementioned
   mis-configuration, it takes 7~8 secs.
 * Until I have further fix, I think it is better to stick to the stable version
   in network 1.
 *  Plugin Author [Nawawi Jamili](https://wordpress.org/support/users/nawawijamili/)
 * (@nawawijamili)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17343178)
 * Hi,
 * The reason why added DOCKET_CACHE_PATH_NETWORK_(n) is to possible to change each
   sub-network cache path, to mount it as a ramdisk.
 * If the ramdisk is not needed for each sub-network, no need to define it.
 * And DOCKET_CACHE_PATH_NETWORK_ constant must be in uppercase to make it work.
 * > It seems like there is little bit of confusion in folder structure. For each
   > sub-network, should I go with /docket-cache/network-x or /docket-cache-x/network-
   > x?
 * Yes, define it outside the default cache directory “wp-content/docket-cache-x/”,
   because we can’t mount ramdisk in mounted ramdisk.
 * > But in WP folders, I can see folder structure like
   > wp-content/docket-cache-
   > datawp-content/docket-cache-data/network-3
 * “wp-content/docket-cache-data” directory is for configuration, nothing changes.
   Cache path configuration is not stored in any file, it’s automatically determined
   by Docket Cache.
 * > Besides, since the RC update, the performance got slower about 50~80%.
 * This is because the cache is not cached properly when the Cache path changes.
   Either you need to stop your webserver remove the cache path manually and start
   it back to populate the cache or just restart the webserver and remove wp-content/
   cache/docket-cache/network-x manually.
 * The RC version only has a chance at the cache path, the code you may find in 
   includes/compat.php at line 580
 *     ```wp-block-code
       if (!\function_exists('nwdcx_network_dirpath')) {
           function nwdcx_network_dirpath($save_path)
           {
            	if (nwdcx_network_multi() && !nwdcx_network_main()) {
                   $network_id = nwdcx_network_id();
                   $cache_dir = sprintf('network-%s', $network_id);
                   $cache_path_constant = sprintf('DOCKET_CACHE_PATH_NETWORK_%s', $network_id);
                   if (\defined($cache_path_constant)) {
                       $save_path = \constant($cache_path_constant);
                       file_put_contents(WP_CONTENT_DIR.'/PL.txt', $save_path);
                   }
                   $save_path = rtrim($save_path, '/').'/'.$cache_dir.'/';
               }
   
       	return $save_path;
           }
       }
       ```
   
 * You may need to remove this leftover code for debug:
 * `file_put_contents(WP_CONTENT_DIR.'/PL.txt', $save_path);`
 * > Until I have further fix, I think it is better to stick to the stable version
   > in network 1.
 * That’s the only fix I can provide to meet your requirements.
 * Thanks.
 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17343843)
 * [@nawawijamili](https://wordpress.org/support/users/nawawijamili/), thx for coming
   back quick.
 * I added # to file_put_contents line as you suggested. I still do not have Object
   cache working in my sub-network, and I wonder if it because of config path being
   the same as cache path. Both are
    - /wp-content/cache/docket-cache-x/network-x
 * From what I can see in the main network,
    - cache path: /wp-content/cache/docket-cache
    - config path: /wp-content/docket-cache-data
 * When it comes to wp-config.php modification for cache path, I have following 
   lines for all sub-networks (x being 2~8)
    - define(‘DOCKET_CACHE_PATH_NETWORK_x’, ‘/var/www/mydomain.com/wp-content/cache/
      docket-cache-x’);
 * (so all are in uppercase, just in case you wonder)
 * Is there anything else I should do? In case it has to be renewed, I have deactivated
   Docket from all main/sub-networks, systemctl restarted php/nginx, reactivated
   Docket, and systemctl restarted php/nginx again.
 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17344167)
 * I give you a couple of findings so that you can do debugging more easily.
 * For the sub-network’s config path, I do not think it can be a big deal, because
   I can find options.php from the config path, and whether it is with other cache
   files in the same folder or not does not seem an important issue.
 * In the /docket-cache-x/ folder, I have no files at all. In the /docket-cache-
   x/network-x folder, I have some files, but not as many as the main network. I
   have over 60,000 files in the main network’s cache path, but I have 625 files
   in the sub network’s cache path.
 * For the cache files limit, I have changed the config that it is 1M acorss network.
 * Immediately after activating Docket in a sub-network, both Object cache and Zend
   OPcache do not work. I run systemctl restart for nginx/php (more precisely for
   php-fpm), then Zend OPcache works, although the files seem shared across networks.
   I have the same stat for the sub-network and the main network. For Object cache,
   I have ‘Not Available’ or ‘0B object of 0 files’.
 * When I try to ‘Flush Object Cache’, then it says I have no cache so nothing to
   flush for.
 * I can pretty much understand what’s going on, except the obvious fact that Object
   cache does not function for sub-networks.
 * One last thing, and I guess this is more important than all of the above. When
   I remove following lines from wp-config.php
    - define(‘DOCKET_CACHE_PATH_NETWORK_x’, ‘/var/www/mydomain.com/wp-content/cache/
      docket-cache-x’);
 * then Object cache seems working. At least I can see files are created, and config
   path / cache path are now different
    - Cache path: /wp-content/cache/docket-cache/network-x
    - Config path: /wp-content/docket-cache-data/network-3
 * Speed of the build-up is not as fast as the main network, but it certainly is
   none-zero.
 * I feel that it is still mis-configured, but not sure where to fix.
    -  This reply was modified 2 years, 4 months ago by [Keith](https://wordpress.org/support/users/keithkhl/).
 *  Plugin Author [Nawawi Jamili](https://wordpress.org/support/users/nawawijamili/)
 * (@nawawijamili)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17344515)
 * Alright then, thanks for the info.
    1. Edit file includes/src/Filesystem.php at line 22,
       and change the code from:
 *     ```wp-block-code
       public function is_docketcachedir($path)
       {
           static $cached = [];
       ```
   
 * to:
 *     ```wp-block-code
       public function is_docketcachedir($path)
       {
           return true;
           static $cached = [];
       ```
   
 * 2. Stop php-fpm/nginx
 * 3. Add back DOCKET_CACHE_PATH_NETWORK_x
 * 3. Remove wp-content/cache/docket-cache and wp-content/cache/docket-cache-x
 * 4. Start php-fpm/nginx
 * Thanks.
 *  Plugin Author [Nawawi Jamili](https://wordpress.org/support/users/nawawijamili/)
 * (@nawawijamili)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17344727)
 * [@keithkhl](https://wordpress.org/support/users/keithkhl/)
 * Please ignore the previous reply and download the fix here [https://docketcache.com/devtest/docket-cache-230802-rc3.zip](https://docketcache.com/devtest/docket-cache-230802-rc3.zip)
 * It fixes configuration path (docket-cache-data) and cache path checking.
    1. Define this constant for main network
 *     ```wp-block-code
       define('DOCKET_CACHE_PATH', '/var/www/mydomain.com/wp-content/cache/docket-cache/main');
       ```
   
 * 2. Define this constant for a sub-network, the path stays the same, it will create
   docket-cache/sub/network-2 and so on.
 *     ```wp-block-code
       define('DOCKET_CACHE_PATH_NETWORK_2', '/var/www/mydomain.com/wp-content/cache/docket-cache/sub');
       ```
   
    1. Stop nginx/php-fpm
    2. Remove wp-content/cache/docket-cache and wp-content/cache/docket-cache-x
    3. Start php-fpm/nginx
 * Hope this will help
 * Thanks.
 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17344803)
 * [@nawawijamili](https://wordpress.org/support/users/nawawijamili/), I was gonna
   say the config gets re-set everytime the cache is purged, since the config path
   is the same as the cache path, but your modification fixed it.
 * I can now really feel that it is workin properly. Just want to let you know that
   cache path for the sub-networks are
    - /wp-content/cache/docket-cache/sub/network-x/network-x
 * Not sure if you need two ‘network-x’.
 * Whether or not, guess the folders to mount to RAM disk are then
    - /wp-content/cache/docket-cache/main
    - /wp-content/cache/docket-cache/sub/network-x
 * Plz correct me if I am wrong.
    -  This reply was modified 2 years, 4 months ago by [Keith](https://wordpress.org/support/users/keithkhl/).
 *  Thread Starter [Keith](https://wordpress.org/support/users/keithkhl/)
 * (@keithkhl)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17344868)
 * Most content are stored in one of the sub-networks, but the main network’s cache
   becomes the largest. It’s like 200M vs 20M between main network and all sub-networks.
   As long as it works I am OK, but would be great to have some sort of understanding
   that why the main network has the largest cache.
 *  Plugin Author [Nawawi Jamili](https://wordpress.org/support/users/nawawijamili/)
 * (@nawawijamili)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/#post-17345023)
 * > Not sure if you need two ‘network-x’
 * “network-x” will be automatically created by the docket cache, you only need 
   to define “DOCKET_CACHE_PATH_NETWORK_2” with “/var/www/mydomain.com/wp-content/
   cache/docket-cache/sub”
 * For the next sub-network, define it with the same path “/var/www/mydomain.com/
   wp-content/cache/docket-cache/sub”
 * “DOCKET_CACHE_PATH_NETWORK_3” with “/var/www/mydomain.com/wp-content/cache/docket-
   cache/sub”
 * > Whether or not, guess the folders to mount to RAM disk are then
   >  - /wp-content/cache/docket-cache/main
   >  - /wp-content/cache/docket-cache/sub/network-x
 * Yes.
 * Thanks.

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/multinetwork-compatibility/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/multinetwork-compatibility/page/2/?output_format=md)

The topic ‘MultiNetwork compatibility?’ is closed to new replies.

 * ![](https://ps.w.org/docket-cache/assets/icon-256x256.png?rev=2425893)
 * [Docket Cache - Object Cache Accelerator](https://wordpress.org/plugins/docket-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/docket-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/docket-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/docket-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/docket-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/docket-cache/reviews/)

 * 16 replies
 * 2 participants
 * Last reply from: [Keith](https://wordpress.org/support/users/keithkhl/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/multinetwork-compatibility/page/2/#post-17345723)
 * Status: resolved