function networkFetch(event, cache, broadcast) {
	var request = event.request,
		cacheControl = readCacheHeader(request);

	return fetch(request)
		.then(function (networkResponse) {
			return randomize(networkResponse); // randomize the response for demonstration
		})
		.then(function (networkResponse) {
			if (networkResponse.ok && cache && cacheControl.isCacheEnabled()) {

				cache.put(request, networkResponse.clone());

				console.log("[CARDS CACHING SW] data revalidated - broadcast to card (" + request.url + ")");
				if (broadcast) {
					postMessage(event, {
						type: "ui-integration-card-update",
						url: request.url
					});
				}
			}

			return networkResponse;
		});
}
//network response put in cache if given
network response put in cache if given
network response put in cache if given
function networkFetch(event, cache, broadcast) {
	var request = event.request,
		cacheControl = readCacheHeader(request);
	return fetch(request)
		.then(function (networkResponse) {
			return randomize(networkResponse); 
		})
		.then(function (networkResponse) {
			if (networkResponse.ok && cache && cacheControl.isCacheEnabled()) {
				cache.put(request, networkResponse.clone());
				console.log("[CARDS CACHING SW] data revalidated - broadcast to card (" + request.url + ")");
				if (broadcast) {
					postMessage(event, {
						type: "ui-integration-card-update",
						url: request.url
					});
				}
			}
			return networkResponse;
		});
}
function networkFetch ( event , cache , broadcast ) { var request = event . request , cacheControl = readCacheHeader ( request ) ; return fetch ( request ) . then ( function ( networkResponse ) { return randomize ( networkResponse ) ; } ) . then ( function ( networkResponse ) { if ( networkResponse . ok && cache && cacheControl . isCacheEnabled ( ) ) { cache . put ( request , networkResponse . clone ( ) ) ; console . log ( "[CARDS CACHING SW] data revalidated - broadcast to card (" + request . url + ")" ) ; if ( broadcast ) { postMessage ( event , { type : "ui-integration-card-update" , url : request . url } ) ; } } return networkResponse ; } ) ; }
network response put in cache if given
network response put in cache if given
// randomize the response for demonstration