Speed up App and iCloud downloads with Content Caching

Discussion in 'macOS High Sierra (10.13)' started by Nugget, Sep 25, 2017.

  1. Nugget macrumors 68000

    Nugget

    Joined:
    Nov 24, 2002
    Location:
    Houston Texas USA
    #1
    With the release of macOS 10.13 High Sierra Apple have made a big change to their App and iCloud content caching services. This used to be part of the add-on macOS Server package, but with 10.13 they've moved the caching service into the regular desktop macOS operating system. This means that any Macintosh computer running 10.13 High Sierra can serve as a content cache for its local network.

    If you have at least one semi-permanent Apple device on your local network you will see benefits from running the caching service. All iOS and macOS application downloads will pass through the cache which means you only have to download them once. This saves your bandwidth and means application installs can run much faster. When some developer does their weekly "Bug fixes and performance improvements" update, all your devices will install it from the cache, fast and saving your bandwidth and data cap.

    If you enable the optional iCloud caching, you'll get similar (and even more noticeable) performance improvements for iCloud Photo Library syncing, iCloud Drive, and other data sharing across your Apple devices.

    When you take a photo with your iPhone it will be uploaded through the caching service to Apple's iCloud servers. Then when your other devices sync that photo via iCloud it will not have to be downloaded from "the cloud" but instead pulls the local, cached image.

    I've been running this service on an old MacBook Air at my house for years now (with macOS Server) and it's been a great benefit when huge application updates roll out.

    The old macOS Server version had fancy logs and graphs that allowed you to monitor cahing performance and activity to keep an eye on the efficacy and health of the service. When they moved it all to regular macOS all that stuff disappeared. It's basically just an on/off checkbox in the Sharing pane of System Preferences.

    Instead, there's just a command-line tool that outputs the raw data from the service. You can see the stats by running a
    Code:
    AssetCacheManagerUtil status
    from a Terminal window.

    Apple have documented (very tersely) the setup at this support page. There are a ton of new fancy options in High Sierra, where you can set up tiered caching with parent and children caches. It also plays a lot better with IPv6 now (Advanced Options, changing it to share to "devices using the same local networks" instead of "devices using the same public IP address"). If you have a lot of Macs and/or iOS devices at your company you should definitely consider turning this on.

    If on the off chance that you're running Zabbix 3.4 for network monitoring, I created a Zabbix template that provides 8x10 color glossy graphs with circles and arrows and a paragraph on the back of each one describing what it all means. If you're not running Zabbix it's definitely not worth installing just for this, but if you already are, boom.

    TL;DR: If you have a Mac at your home or office that's always turned on and connected to the network (an old iMac or Mac Mini work great for this) go to "Sharing" in System Preferences and turn on the Content Caching service. It's simple and a huge win for even small networks
     
  2. Nugget thread starter macrumors 68000

    Nugget

    Joined:
    Nov 24, 2002
    Location:
    Houston Texas USA
    #2
    Edit to add: You can also view the asset cache logs by running the macOS Console (in Applications/Utilities) and searching for "AssetCache" like this:
     

    Attached Files:

  3. GuilleA macrumors regular

    GuilleA

    Joined:
    Jun 8, 2015
    Location:
    Buenos Aires
    #3
    I've been wanting this for a long time. Pretty much the only feature I only used from macOS Server was Time Machine server and Content Caching. Seems they understood that was the most popular scenario.

    I've just updated my Mac mini acting as a central hub for my household and enabled Content Caching. Apple's documentation is rather confusing, only mentioning tethered caching for iOS device via USB, and that you need to enable Internat Sharing. I enabled it, set a storage limit for it and then proceeded to download the 11.0.1 iOS update on my iPhone. I was expecting for it to go the cache, but the options pane still show None used (instead of the 280MB of the patch).

    I didn't enable iCloud Caching nor Share Internet connection.

    After checking the console, I see no activity for AssetCache. No results are found.
     
  4. Nugget thread starter macrumors 68000

    Nugget

    Joined:
    Nov 24, 2002
    Location:
    Houston Texas USA
    #4
    You're right that the documentation is confusing. There's no need to enable Internet Sharing at all, I think you're right that it's only required for USB cabled tethered caching for iOS devices.

    The default setting for the regular Content Caching follows the same model as the old macOS Server caching. The cache registers with Apple's servers and Apple makes note of the public IP that your server came in on. When other devices on your network (behind the same NAT, presumably) talk to Apple, their end notices the same public IP and redirects the device to your internal IP instead. It's not a totally stupid way to do things, although it does assume that there's no IPv6 and that you've got a normal NAT environment with a single outbound public IP.

    Under advanced options the High Sierra service offers a new mechanism which I'm using here and much prefer. Change the Clients setting to "devices using the same local networks." This seems to turn on a brand new zeroconf broadcast which iOS and macOS clients use to search out and discover local caching servers even before trying to talk to Apple.

    I've observed this scan and response by watching AssetCache logs on the client side which yields logs like this:

    Code:
    #6eceb3ec [AssetCacheLocatorService.queue] found 1 caching server (10.20.30.40:49242); all with matching capabilities, sorted=NO
    
    #6eceb3ec ACSLocateCachingServer -> [new] newURL http://10.20.30.40:49242/content/downloads/04/61/091-34298/almpfkbhyxnsgbxxqhoqo7sb40w3uip0wk/RecoveryHDMetaDmg.pkg?source=swcdn.apple.com, advice {
        connectTimeout = "0.5";
        supportsUrgency = 1;
        validUntil = "2017-09-26 22:01:11 +0000";
    }, error (null), elapsed 0.607/30.000
    
    ...then I see corresponding traffic on the server side pulling and serving the data.

    This works equally well for both iOS and macOS devices as long as they're in the same local network (broadcast traffic).

    Hope that works better for you.
     
  5. GuilleA, Sep 26, 2017
    Last edited: Sep 26, 2017

    GuilleA macrumors regular

    GuilleA

    Joined:
    Jun 8, 2015
    Location:
    Buenos Aires
    #5
    Thank you for the info, that was very thorough. I had some ideas on how Content Caching works but you're certainly far more versed in it than I am.

    I've set the options exactly as you suggested, and proceeded to download another iOS 11.0.1 update on a different device. The cache still says CachedUsed = 0. It's really confusing. All my devices are on the same local network (no subnets), connected to the same router (NAT and DHCP). I don't have any other network issue whatsoever.

    The AssetCacheManagerUtil output is as follows:

    Code:
    AssetCacheManagerUtil[1045:37547] Built-in caching server status: {
        Activated = 1;
        Active = 1;
        CacheDetails =     {
        };
        CacheFree = 201000000000;
        CacheLimit = 201000000000;
        CacheStatus = OK;
        CacheUsed = 0;
        Parents =     (
        );
        Peers =     (
        );
        PersonalCacheFree = 201000000000;
        PersonalCacheLimit = 201000000000;
        PersonalCacheUsed = 0;
        Port = 49232;
        PrivateAddresses =     (
            "192.168.0.20"
        );
        PublicAddress = "*.*.*.*";
        RegistrationStatus = 1;
        RestrictedMedia = 0;
        ServerGUID = "B484972A-F5EE-42ED-BFE0-5C11B3D680F4";
        StartupStatus = OK;
        TotalBytesDropped = 0;
        TotalBytesImported = 0;
        TotalBytesReturnedToChildren = 0;
        TotalBytesReturnedToClients = 0;
        TotalBytesReturnedToPeers = 0;
        TotalBytesStoredFromOrigin = 0;
        TotalBytesStoredFromParents = 0;
        TotalBytesStoredFromPeers = 0;
    }
    I masked my public IP but I confirmed it's correct.
    Also, here are some screenshots from System Preferences:

    Screen Shot 2017-09-26 at 18.13.37.png Screen Shot 2017-09-26 at 18.13.52.png Screen Shot 2017-09-26 at 18.13.59.png
    --- Post Merged, Sep 26, 2017 ---
    EDIT: Hold on. I just updated and app on my iPhone and the Storage Used in the cache bumped up to 7MB. So I guess it is working after all. After updating a few more apps the cache is now at around 238MB.
     

Share This Page

4 September 25, 2017