import {StorageLocal} from "gs-br-ext";

export async function cacheFetch(	input: string | URL | globalThis.Request,init?: RequestInit): Promise<Response> {
	init || (init = {});
	init.cache = await StorageLocal.getValue('cache')
	console.log(new Date().toLocaleTimeString(),'cache:',init.cache,',execute url=', input)
	return await fetch(input, init);
}

export async function isCache() {
	return 'force-cache' === await StorageLocal.getValue('cache');
}