Enterprise Level Asset Caching OSX High Sierra
Since iOS 10.0+ and Sierra 10.13.1+ Apple has moved their caching from the Server App to OSX itself. If you previously had settings for the Server App caching services will no longer start. After a fair bit of digging around I found a fair few details have changed internally that have to be manually updated. I will cover multiple external IP addresses and sub nets as well.
Upgrading from 10.13.1 to 10.13.5
You may also have the same issue I had with OSX 10.13.1, when looking at the AppStore you notice there is no updates available for OSX but there is an update for the Server App.
The only way around this is to install the combo update from Apple here: https://support.apple.com/kb/dl1953?locale=en_AU
After this installs you can update via the AppStore, if the AppStore still doesn’t work you can update manually using a similar process.
What’s changed with High Sierra Cache?
The main difference with the OSX cache sharing verses the Server App is the File Hierarchy that stores the cache has changed. It now requires the following folders to be created before the service will start /Library/Application Support/Apple/AssetCache/Data.
If you’re running a larger external hard drive you will need to make the folders there instead. You can do this by using the following command in Terminal replacing usbname with the name of your usb storage device.
External:
Mkdir –p “/Volumes/usbname/Library/Application Support/Apple/AssetCache/Data”
Local:
Mkdir –p “/Library/Application Support/Apple/AssetCache/Data”
Enter Root access for the rest of this guide #:
sudo su
It also defaults to using en1(wireless) instead of en0(Ethernet) as the interface. Open Network Utility to ensure en0 is Ethernet, fix this by running the following code in Terminal:
/usr/bin/AssetCacheManagerUtil Interface en0
If you’re using a multi sub net run the following code in Terminal. Replace the first and last ip address with the start of your subnet to the end of your subnet, if you’re unsure on what these are set to check your DHCP server scope.
/usr/bin/AssetCacheManagerUtil ListenRanges '({first = 10.0.0.1; last = 10.0.0.254; })'
Apply these settings run the following code in Terminal, if you have a basic network with one external IP address this should get you back into action.
AssetCacheManagerUtil deactivate AssetCacheManagerUtil activate
If it doesn’t start and shows an orange light instead of green, ensure you have set a Static IP address in network settings.
I have multiple external IP addresses, it “works” but isn’t very efficient.
The main issue with having multiple external IP addresses is that clients will randomly select one and only look for cache servers on that external IP.
By default your Mac is set to use a single external IP, if you have 5 external IP addresses clients only see a cache server 20% of the time. The old solution was to make all traffic going to 17.0.0.0/8 to be Direct through proxy settings. This is no longer works as Apple has slowly moved over to IPV6 addresses.
You can find your external IP addresses by searching “What is my IP Address” into your favourite search engine, check over the span of a few minutes and see if it changes. Run the following code in Terminal replacing the first/last ip addresses with however many external ip addresses you have. You can also set this in the Content Caching Preferences.
AssetCacheManagerUtil PublicRanges '({first = 210.0.0.1; last = 210.0.0.1; }, {first = 210.0.0.60; last = 210.0.0.60;})'
Multiple external IP Addresses also requires DNS entries, Open PowerShell and run the following code below. Replace the dnsServerName, DomainName and external IP addresses.
dnscmd dnsServerName /RecordAdd DomainName _aaplcache._tcp 259200 TXT "prs=210.0.0.1,210.0.0.60"
Additional Configuration
Set the Port and allow access,
/usr/bin/AssetCacheManagerUtil LastPort 49416 /usr/bin/AssetCacheManagerUtil Port 49416
Open server App > ServerName > Access > + button > TCP 49416 > only some networks > start subnet, end subnet.
To prevent iCloud Data from being cached run the following code to disable
/usr/bin/AssetCacheManagerUtil AllowPersonalCaching false
To prevent cache from filling storage device run the following code
/usr/bin/AssetCacheManagerUtil AllowCacheDelete true
Amount of space to reserve before cache is deleted, this is set to 2Gb by default. if its running locally I suggest setting it to the amount of ram installed.
/usr/bin/AssetCacheManagerUtil ReservedVolumeSpace 2000000000
Below prevents cache manager from searching outside of your selected subnet.
/usr/bin/AssetCacheManagerUtil ListenRangesOnly true
set this to false or it will only search a /24 subnet
/usr/bin/AssetCacheManagerUtil LocalSubnetsOnly false
set this to false or it will only peer to one external IP address
/usr/bin/AssetCacheManagerUtil PeerLocalSubnetsOnly false
Final steps
Open system preferences> Sharing> tick content caching if not already ticked (it most likely won’t start this is normal)
Restart the Mac
Open system preferences click on sharing, see that the caching server is in an “on” state.
Restart an iPad to test (others will automatically find the server over time aka on next wireless join)
Download an app, delete it then download it again
Open Activity Monitor click on cache tab and see if it’s working. if it isn’t check your plist file and compare it to the example below
Manually change the plist file.
From terminal run the following code:
nano /Library/preferences/com.apple.assetcache.plist
Changes required are in bold, comments will be written in italics they are not part of the code, do not copy/paste as there is more code than what is listed, this is just what is required to be changed, you will know assetcache is working when this updates with 400 new lines of data in the <key>LastConfigData</key> area.
<key>Activated</key> <true/> <key>AllowCacheDelete</key> <true/> <key>AllowPersonalCaching</key><false/> this is iCloud data and is not recommended <key>CacheLimit</key><integer>0</integer> unlimited size <key>DataPath</key> If not using an external drive remove /Volumes/usbname leaving /Library/… <string>/Volumes/usbname/Library/Application Support/Apple/AssetCache/Data</string> <key>Interface</key> <string>en0</string> open Network Utility to ensure its ethernet <key>LastPort</key><integer>49416</integer> <key>ListenRanges</key><array><dict> <key>first</key><string>10.0.0.1</string> Start of subnet <key>last</key><string>10.0.5.255</string> End of subnet </dict></array> <key>ListenRangesOnly</key> <true/> this must be true or it will search for all other subnets <key>LocalSubnetsOnly</key> <false/> this must be false or it will only search a /24 subnet <key>ParentSelectionPolicy</key><string>first-available</string> <key>PeerFilterRanges</key> <array><dict> <key>first</key><string>10.0.0.1</string> Start of subnet <key>last</key><string>10.0.5.255</string> End of subnet </dict></array> <key>PeerListenRanges</key> <array><dict> <key>first</key><string>10.0.0.1</string> Start of subnet <key>last</key><string>10.0.5.255</string> End of subnet </dict></array> <key>PeerLocalSubnetsOnly</key><false/> <key>Port</key><integer>49416</integer> <key>PublicRanges</key> <array><dict> <key>first</key><string>210.0.0.1</string> replace with external ip address <key>last</key><string>210.0.0.1</string> replace with external ip address </dict><dict> <key>first</key><string>210.0.0.60</string> replace with external ip address <key>last</key><string>210.0.0.60</string> replace with external ip address </dict><dict> <key>ReservedVolumeSpace</key> <integer>2000000000</integer> This is 2GB
To save push ctrl+o then ctrl+x to quit
Restart your mac.
Results
The internet usage has dropped from 719.46Gb to 318.52Gb saving around 400Gb bandwidth and reducing the stress on our internet connection. This is with around 1200 devices using the cache.
Last week(without cache)
This week(with cache)
Cache was turned on and working Monday of This week.
Apple downloads alone have gone from 329Gb Last week to 190Gb This week so we have saved 139Gb.
If you have a large enterprise network with BYOD devices MDM/VPP apps you will benefit greatly from having your cache setup correctly.
This Post Has 2 Comments
How do I setup my MAC caching server to provide me with usage graphs? Is there a tool I can use for this? The built in graphs is not convenient and I need to export it out.
I used a squid Proxy server to generate the internet usage, the newer versions of OSX have graphs in Activity Monitor to let you know the cache usage.