ContentPrefetcher ContentPrefetcher ContentPrefetcher ContentPrefetcher Class


Provides properties for specifying web resources to be prefetched. Windows will use heuristics to attempt to download the specified resources in advance of your app being launched by the user.

public : static class ContentPrefetcherpublic static class ContentPrefetcherPublic Static Class ContentPrefetcher// You can use this class in JavaScript.
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


Many categories of apps need to download significant amounts of web content upon launch. This can result in poor user experiences where users must wait for content to load before the app becomes fully functional. The ContentPrefetcher class provides mechanisms for specifying resources that Windows should attempt to download in advance of your app being launched by the user.

Heuristics are used to determine when prefetching should occur and which resources will be downloaded. These heuristics take into account system network and power conditions, user app usage history, and the results of prior prefetch attempts to provide maximum user benefit, but there is no guarantee that any particular resource will have been downloaded before a given app launch.

Resources that have been successfully prefetched will be placed in the app-specific WinINet cache. No changes are required to existing HTTP requests for these resources once the app is running; WinINet will simply transparently serve the content from cache if it is available. In the event that a requested resource was not prefetched, an HTTP request for content simply results in a cache miss, and the request is made to the server. Note that this caching strategy works for HTTP requests made using WinJS.xhr, Windows.Web.Http.HttpClient, and IXMLHTTPRequest2 interface. The .NET Framework HttpClient is not supported.

The ContentPrefetcher class provides two mechanisms for specifying resources that should be prefetched:

An example would be prefetching images for the latest news articles, the news articles and corresponding images change frequently and the XML file can be kept up to date with the latest URIs to prefetch. Apps may use both properties to specify resources to prefetch. Note that a maximum of 40 content URIs are supported and resources specified via the ContentUri property will be downloaded in preference to those specified by the IndirectContentUri XML. You should prioritize prefetching content that a user first sees, or that a user frequently uses in order to gain the most benefit from the prefetching operation. You should indicate content that has a reasonably long lifetime for your app. Do not prefetch content that has an immediate or very short expire time, or content that would be retired from a user’s view in a short period of time. Short lived content is a poor choice for prefetched content as it is likely that the content would expire or not be show before the app is used and hence not be a benefit for users.

As mentioned above, the system determines when prefetching is performed for an app. For development purposes, however, you can initiate immediate prefetch for your app by calling the IContentPrefetcherTaskTrigger interface desktop API.

To aid in debugging, you can listen to ETW events on the Microsoft-Windows-BackgroundTransfer-ContentPrefetcher channel. Occurrences like initiation and completion of prefetching, initiation and completion of an HTTP request, and XML validation will trigger events.


ContentUris ContentUris ContentUris ContentUris

Array of URIs to download when prefetch is performed for the app.

public : static IVector<Uri> ContentUris { get; }public static IList<Uri> ContentUris { get; }Public Static ReadOnly Property ContentUris As IList<Uri>// You can use this property in JavaScript.
IVector<Uri> IList<Uri> IList<Uri> IList<Uri>

A list of Uri objects.


The following example demonstrates the creation and assignment of URIs for prefetching:

//First, create content URIs
var uris = [new Windows.Foundation.Uri(""),
            new Windows.Foundation.Uri("")];

//clear the old list
Windows.Networking.BackgroundTransfer.ContentPrefetcher.IndirectContentUri = null; // Remove this if your app never uses IndirectContentUri

//next set these as the content URIs:
See Also

IndirectContentUri IndirectContentUri IndirectContentUri IndirectContentUri

Specifies the location of a well-formed XML file that contains a list of resources to be prefetched.

public : static Uri IndirectContentUri { get; set; }public static Uri IndirectContentUri { get; set; }Public Static ReadWrite Property IndirectContentUri As Uri// You can use this property in JavaScript.
Uri Uri Uri Uri

A Uri for a web resource.


The specified resource will be downloaded at the beginning of a prefetch task for an app. Fetching this URL must return a well formatted XML list of additional resources to prefetch.

This resource must be of type application/xml and must adhere to the following schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="">
  <xs:element name="PrefetchUris">
        <xs:element minOccurs="1" name="uri" type="xs:anyURI" />

For example:

<?xml version="1.0" encoding="utf-8"?>

Azure Mobile Services is an option for developers wishing to host a prefetch XML file. To learn more about Azure Mobile Services, see the Dev Center.

See Also

LastSuccessfulPrefetchTime LastSuccessfulPrefetchTime LastSuccessfulPrefetchTime LastSuccessfulPrefetchTime

Gets the date and time of the last successful content prefetch operation.

public : static IReference<DateTime> LastSuccessfulPrefetchTime { get; }public static Nullable<DateTimeOffset> LastSuccessfulPrefetchTime { get; }Public Static ReadOnly Property LastSuccessfulPrefetchTime As Nullable<DateTimeOffset>// You can use this property in JavaScript.
IReference<DateTime> Nullable<DateTimeOffset> Nullable<DateTimeOffset> Nullable<DateTimeOffset>

A 64-bit signed integer that represents a date and time.