Configuring the BranchCache Publication Hash Cache

For those of you using BranchCache, for example to reduce the network impact Windows 10 will have on your environment, I highly recommend changing the size and default for the BranchCache Publication Cache. Why you ask? Well, the default settings are just not good enough.

Background Info

In the Windows 10 era, especially when starting to implement BranchCache with ConfigMgr, and/or enabling DOINC too, you're going to find that the BranchCache publication cache can grow to several GB. The thing is, the default size is 1% of the OS volume, and it's obviously stored on the OS volume to. That means if your DP's have a 60 GB OS volume, the default publication size is going to be 0.6 GB, which is simply not enough.

Moving the Publication Hash Cache

To move the BranchCache Publication Cache to a data disk / volume, and set the size, simply run the below little PowerShell snippet.

Credits: Big thanks to Phil Wilcock for syntax help, and for this blog post: https://2pintsoftware.com/resizing-the-branchcache-cache-powershell/

$NewHashFolder = "E:\BCPublicationCache"
$NewHashSize = 10GB

New-Item -Path $NewHashFolder -ItemType Directory
$BCCache = Get-BCStatus
Set-BCCache -Path $BCCache.HashCache.CacheFileDirectoryPath -MoveTo $NewHashFolder -Force

$BCHashCache = Get-BCHashCache
$BCHashCache | Set-BCCache -SizeBytes $NewHashSize -Force

Or you can set it for percent of a disk:

$NewHashFolder = "E:\BCPublicationCache"
$NewHashSizeInPercent = 5

New-Item -Path $NewHashFolder -ItemType Directory
$BCCache = Get-BCStatus
Set-BCCache -Path $BCCache.HashCache.CacheFileDirectoryPath -MoveTo $NewHashFolder -Force

$BCHashCache = Get-BCHashCache
$BCHashCache | Set-BCCache -Percentage $NewHashSizeInPercent -Force

Verifying the configuration

To verify the configuration, simply run the Get-BCHashCache PowerShell cmdlet.

Running the Get-BCHashCache PowerShell cmdlet.

Supporting legacy servers

For those of you still running Windows Server 2008 R2 (you really shouldn't have them anymore), here is the netsh version that you can run in your favorite console (Command Prompt, PowerShell, Windows Terminal).

Note: These commands will actually delete the existing cache, and sometimes you will have to stop the BranchCache service for the set publicationcache part to work).

netsh branchcache flush
md E:\BCBranchCache
netsh branchcache set publicationcache directory=E:\BCBranchCache
netsh branchcache set publicationcachesize 10737418240

Or you can set it for percent of a disk:

netsh branchcache flush
md E:\BCBranchCache
netsh branchcache set publicationcache directory=E:\BCBranchCache
netsh branchcache set publicationcachesize size=10 percent=TRUE

About the author

Johan Arwidmark

0 0 votes
Article Rating
Subscribe
Notify of
guest
8 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Moh Kokoy
Moh Kokoy
2 years ago

Thanks for the post.
Is there a way to run the flush command on the remote computer ( net branchcache flush)?

Fredrik
Fredrik
3 years ago

Hello,
What about the data cache location/size. Should this be moved/changed or perhaps it doesn't matter?

Rickard
Rickard
3 years ago

Hi.
Is Publication Hash Cach used for packages that Branchcache enabled clients have the opportunity to share? I didn't think the server needed to store anything in the cache, only that the clients had the packages in their cache to share within same subnet.

Ricky Kollberg
Ricky Kollberg
3 years ago

Hi Johan can the location of Publication Hash Cache reside on a deduped volume?


>