SPF is designed to enable fast navigation, and the best way to speed up a navigation request is to not make it all. Prefetching allows you to fetch responses before they are requested and store them in the local cache until they are needed. You can also prefetch scripts and styles to prime the browser cache.
Prefetching a response is done by calling the spf.prefetch function, which behaves nearly identically to spf.navigate and accepts the same callbacks and cancellations when passed an object that conforms to the spf.RequestOptions interface. A list of callbacks follows:
||Started; Sending Prefetch||Abort|
||Processing; Response Received||Abort|
When SPF sends the prefetch request to the server, it will
append the configurable identifier to the URL in the same manner
as navigation; by default, this value will be
When the prefetched response has been received, SPF will place
it in the local cache as eligible for one "new" navigation.
After that one use, the cached response will only be eligible
for "history" navigation. However, if the
config value is set to
true, then the prefetched response will
be available for all navigations like other cached responses.
For more information, see when the cache is used.
When SPF processes a prefetched response, it will prefetch any resources to ensure the browser cache is primed. Fetching JS and CSS files before they are needed makes future navigation faster.
To manually prefetch resources, the following API functions can be used:
Prefetches one or more scripts; the scripts will be requested but not loaded. See also the API reference for spf.script.prefetch.
Prefetches one or more stylesheets; the stylesheets will be requested but not loaded. See also the API reference for spf.style.prefetch.