BITS Download - from HTTP (DP) - BranchCache

BranchCache, it's wonderful. To see some tests and more info, check out this post from Mike Terrill. This post is a bit of an overview of BranchCache, then a script I'm using to trigger downloads of content using PowerShell to populate content into BranchCache from a DP (outside of CM).

The idea behind this script is to pre-cache content using powershell. Sure you can run a pre-cache Task Sequence, and 95% of the time, that's exactly what you'll do, run a Pre-Cache TS to have your content download ahead of time. But sometimes, you just need a quick way to trigger a download to get the content flowing, without waiting for policy, without having to trigger the TS.

When you leverage BranchCache, your dependency on the CCMCache is much less. The CCMCache becoming more of a staging / execution cache, and BranchCache is where your actual payload resides.

Alternate Content Provider (ACP): A tool used to provide the content for CM instead of the standard CM BITS job.

How BranchCache work.
When CM needs content, it checks the CM Cache, is it there? If Yes.. you're good... move along... if no, CM Client checks for DPs and creates location in CCMCache for content to go -> ACP (BranchCache) takes over and pulls down the content into it's own cache location, it will first look to it's own cache to see if it has any bits of it, then to peers for any bits of it, then to the DP last to pull the content from. It then builds the files in the CCMCache from the bits in the BranchCache at the location which the CM Client provisioned. ACP then notifies the CM Client that the download is done and hands back to CM. CM then starts the Install or whatever it was going to do with the content requested.


So once the content is in BranchCache, anytime CM needs it, it can pull it back from the BC Cache, and populate it in it's own CCM Cache. Basically this means you can continue to flush your CCM Cache frequently, as all of the "BITS" are in BranchCache and if you need them again, it will pull from there.

Why would you want to to leverage BranchCache's Cache instead of the CCMCache? It's deduplicated for one, it's block aware for two, and it's cool. You know what I hate, when I bump content because of 1 small file, but now CM needs to download the full payload for that content item again (v2 instead of v1). With BranchCache since v2 and v1 are basically identical, it only needs to pull the delta unlike CCMCache would.

Another benefit of BranchCache, is it can pull from peers, combined with dedup, this really amazing. Like I said at the start, check out Mike's Post to see some examples.

OK... so now the Script... what it does...
You feed it a package id (I'd assume it works with other content, just haven't tested), and it will pull it from the DP's HTTP server using BITS. It downloads the data to a temporary folder in the temp, but is using BC, so it will also be in the BCCache, once downloaded, it deletes itself from the temporary location, leaving it only in the BCCache. Then in the future, when CM needs the content and makes the calls, it will find the content in the BCCache and pull from there. If you look at my crudely made image above, we're using powershell to grab content manually and shove it into the BranchCache so it's already there when CM needs it. (Precache), see 2nd crude drawing below.

Worthwhile to note, you might need to change the script based on your environment, proxy servers, etc, HTTPS vs HTTP. I know it works well in my lab, but every environment is different. Mileage may vary.

Script in Action

First Run, Content is not in the BranchCache and pulling 100% from DP
The next time the files need to be downloaded, they are already in the BranchCache and it's pulls 100% of the content from the local cache instead of the DP. (aka Pre-Cache)

GARYTOWN.COM

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.