OS X Server Caching

| Comments

I knew since September that the server caching feature was coming to OS X and I have to say that I was excited to get my hands on it.

It is a great feature that offers bandwidth saving with no client configuration. As always it is better to configure one server than thousands of clients. Don’t you think?

For the caching server configuration the options are few. Basically you can:

  • Decide how much space you want to dedicate for the cache and on which hard drive you want to store it.
  • Enable or disable the caching server
  • Delete all cached updates and apps

This is what the server does automatically without any visual clue for you:

  • The server launches the AssetCache process as the _assetcache user
  • A LaunchDaemon is created for the service
  • The cache server registers online with Apple and provides it’s public IP, your servers local IP, internal DNS name? (not sure of the dns)
  • It gets in return a validation key to prove to client computers its authenticity
  • Creates the folder /Library/Server/Caching/Data to store the cached downloads

When a client tries to download an app or download a software update:

  • Contacts Apple
  • Apple checks if there is any caching server registered for that public IP
  • If there is one Apple returns to the client the details of the caching server
  • The client computer contacts the caching server and requests the update or app
  • The server identifies itself as a valid/trusted source with the validation key
  • The caching server downloads the app or update if it doesn’t have it, and then serves it to the client computer

You should know:

  • For now only 10.8.2 clients get any benefit of this.
  • iOS devices do not benefit from this service
  • The caching server caches both App Store purchases and software updates
  • If a client computer is pointing manually to a custom SUS the caching server is ignored (does this also affect app purchases?)
  • The SUS service and the caching service do not share their data. You might end up with two copies of all the updates
  • There is no need for you to re-direct connections using DNS trick anymore
  • If you are not directly configuring clients to point to your local SUS but using DNS tricks. You will probably end up deleting the local SUS and cleaning the DNS table. The caching server is for you!
  • Evey 55 minutes your caching server will contact Apple to verify the public IP still the same and get a new token (see next log below)
2012/12/09 19:57:39:041  Request for registration from failed: HTTP response 401, body "REQUEST_REAUTH"; retrying with new token
2012/12/09 19:57:39:317  Request for registration from succeeded
2012/12/09 19:57:39:317  Got back public IP

There is not much documentation available at the moment. Here you have how the control pane, and by clicking it you’ll download the help page

In case you are wondering, the real log file does not seem to be available from the for some reason. The server app offers a grep of the system.log instead? bug?

In any case the log file is located at /Library/Server/Caching/Logs/Debug.log and here is a truncated output of first a successful server download for a client and second the server offering an update that was cached already (0 downloaded)

bash-3.2$ cat /Library/Server/Caching/Logs/Debug.log
2012/12/10 19:32:46:427  ECResponse[0x7fdc1a41c060]: Got request for host =
2012/12/10 19:32:46:428  ECAssetHandler[0x7fdc1a4173b0]: Initializing asset handler for (path = /Library/Server/Caching/Data/FD4F6203-345D-43C9-B7A8-0DD3D12085E5)
2012/12/10 19:32:46:428  ECAssetHandler[0x7fdc1a4173b0]: Cached asset length = 399791345 MD5=<3ac79d7e 87d4488f 3e26ff01 cb1dbfc3> last modified Tue, 04 Dec 2012 02:54:54 GMT
2012/12/10 19:32:46:429  ECAssetHandler[0x7fdc1a4173b0]: Extents loaded from disk: [0,399791345]
2012/12/10 19:32:46:429  ECAssetHandler[0x7fdc1a4173b0]: Request had no range headers
2012/12/10 19:32:46:429  ECAssetRequestor[0x7fdc1b018030]: Data already cached for asset, issuing If-Modified-Since request
2012/12/10 19:32:47:093  ECResponse[0x7fdc1a41c060]: Info loaded: file length = 399791345, reader = 0x7fdc1a41aed0
2012/12/10 19:32:47:094  ECCacheReader[0x7fdc1a41aed0]: fetchDataOfLength called with file closed at offset 0
2012/12/10 19:32:47:094  ECAssetHandler[0x7fdc1a4173b0]: Opened extent [0, 399791345] for reading at offset 0 (offset into file = 0)
2012/12/10 19:32:47:094  ECCacheReader[0x7fdc1a41aed0]: opened offset [0, 399791345]
2012/12/10 19:32:47:095  ECAssetRequestor[0x7fdc1b018030]: Outgoing connection finished
2012/12/10 19:35:44:342  ECResponse[0x7fdc1a41c740]: Got request for host =
2012/12/10 19:35:44:344  ECAssetHandler[0x7fdc1a46c920]: Initializing asset handler for (path = /Library/Server/Caching/Data/5128AF14-D64B-4865-A76C-66BD571BA2F2)
2012/12/10 19:35:44:344  ECAssetHandler[0x7fdc1a46c920]: Cached asset length = 47543 MD5=<805a210f 4129352c 69fdcea0 05345dbe> last modified Mon, 03 Dec 2012 18:36:03 GMT
2012/12/10 19:35:44:344  ECAssetHandler[0x7fdc1a46c920]: Extents loaded from disk: [0,47543]
2012/12/10 19:35:44:344  ECAssetHandler[0x7fdc1a46c920]: Request had no range headers
2012/12/10 19:35:44:344  ECAssetRequestor[0x7fdc1dd02f00]: Data already cached for asset, issuing If-Modified-Since request
2012/12/10 19:35:45:282  ECResponse[0x7fdc1a41c740]: Info loaded: file length = 47543, reader = 0x7fdc1a46f660
2012/12/10 19:35:45:282  ECCacheReader[0x7fdc1a46f660]: fetchDataOfLength called with file closed at offset 0
2012/12/10 19:35:45:282  ECAssetHandler[0x7fdc1a46c920]: Opened extent [0, 47543] for reading at offset 0 (offset into file = 0)
2012/12/10 19:35:45:282  ECCacheReader[0x7fdc1a46f660]: opened offset [0, 47543]
2012/12/10 19:35:45:282  47543 bytes served, 47543 from cache, 0 downloaded
2012/12/10 19:35:45:282  ECCacheReader[0x7fdc1a46f660]: canceled at offset = 47543
2012/12/10 19:35:45:282  ECAssetHandler[0x7fdc1a46c920]: Asset has no clients:
2012/12/10 19:35:45:282  ECAssetHandler[0x7fdc1a46c920]: Removed reader 0x7fdc1a46f660, will cancel 0 requestors
2012/12/10 19:35:45:282  Total bytes returned to clients 2786669731, total bytes requested from servers 388568166
2012/12/10 19:35:45:283  ECAssetRequestor[0x7fdc1dd02f00]: Outgoing connection finished