ylliX - Online Advertising Network
Understanding the Mac's advanced content caching settings

Understanding the Mac’s advanced content caching settings


Content cache settings in macOS Sequoia.



Advanced configuration parameters control how your Mac stores cached content. Here’s how to change the settings.

Content caching controls what internet content gets stored locally in macOS when you visit websites and other online servers.

When you visit a site, some of the data (content) gets downloaded and stored locally on your Mac. This is so that if you access that content later, it can be loaded more quickly from the cache – instead of having to make more trips to the internet to fetch it again.

In order to use content caching on the Mac, you must first enable it in System Settings->General->Sharing->Content Caching.

When you do this you’ll get a sheet allowing you to set what content you want cached: All Content, Shared Content, or iCloud Content.

You can also select whether or not you want to share your internet connection and (if you click the Options button) where to store the content cache and how large it should be. After you turn content caching on, you’ll be prompted to restart your Mac or other devices.

Where the cache settings are stored

The Mac stores the content cache settings in a .plist (XML) file at /Library/Preferences/com.apple.AssetCache.plist on your Startup Disk. You can open this file in a text editor, or in Apple’s Xcode, to edit its settings.

Apple specifically says only to change some of the settings in this file. The others are off-limits, and if you change them, it could cause your Mac to malfunction or be rendered unusable.

See below for the full list.

macOS's contents cache .plist file.

The com.apple.AssetCache.plist file.

AssetCacheManagerUtil

If you don’t want to edit the settings directly in the .plist file, you can instead edit them in macOS’s Terminal app by using the AssetCacheManagerUtil command-line tool.

To get more info on AssetCacheManagerUtil in Terminal type:

man AssetCacheManagerUtil and press Return.

You’ll need to use the sudo prefix when using the AssetCacheManagerUtil tool.

When you’re done changing your content cache settings, force a reload of the settings by using the reloadSettings option for the AssetCacheManagerUtil tool:

sudo AssetCacheManagerUtil reloadSettings

Apple states some values require you to stop and then restart Content Caching in System Settings.

You can also use the defaults system in Terminal to set simple and advanced settings. To view all standard content cache settings in Terminal type:

sudo AssetCacheManagerUtil settings and press Return.

You can also change the .plist file's settings in Apple's Xcode.

Editing the .plist file in Xcode.

JSON

For more complex commands you’ll need to know how to use the defaults system in Terminal, and how to write JSON (JavaScript Object Notation) to pass parameters to the defaults system.

JSON is essentially key-value pairs stored in plain text, which can be nested with data separated by commas and curly braces.

For example, '( { first = 10.0.0.1; last = 10.0.0.254; }, { first = 10.1.0.1; last = 10.1.0.254; } )' contains an array of 2 keyed dictionaries with first and last keys set to different internet addresses.

JSON is actually fairly easy to write and understand once you know how the syntax and nesting works.

JSON is widely used all over the internet to pass and store data. A dictionary is just a set of key/value pairs bundled together for easy access.

Which values to change

Some of the values in com.apple.AssetCache.plist must be clamped between two allowable values. Don’t change these to anything outside their allowed ranges.

By changing these values you can alter quite a lot of how the content cache behaves including timeouts, limits on how big the cache can be, disk space, alerts, and more.

You can also set the verbosity level of the cache logs if you want more information about the way it behaves.

By altering these settings you can control and change how your Mac stores, loads, and deletes content caches.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *