klemenoslaj a2068523fd feat(service-worker): add the option to prefer network for navigation requests (#38565)
This commit introduces a new option for the service worker, called
`navigationRequestStrategy`, which adds the possibility to force the service worker
to always create a network request for navigation requests.
This enables the server redirects while retaining the offline behavior.

Fixes #38194

PR Close #38565
2020-09-22 09:29:20 -07:00

50 lines
1.2 KiB
TypeScript

export declare interface AssetGroup {
cacheQueryOptions?: Pick<CacheQueryOptions, 'ignoreSearch'>;
installMode?: 'prefetch' | 'lazy';
name: string;
resources: {
files?: Glob[];
urls?: Glob[];
};
updateMode?: 'prefetch' | 'lazy';
}
export declare interface Config {
appData?: {};
assetGroups?: AssetGroup[];
dataGroups?: DataGroup[];
index: string;
navigationRequestStrategy?: 'freshness' | 'performance';
navigationUrls?: string[];
}
export declare interface DataGroup {
cacheConfig: {
maxSize: number;
maxAge: Duration;
timeout?: Duration;
strategy?: 'freshness' | 'performance';
};
cacheQueryOptions?: Pick<CacheQueryOptions, 'ignoreSearch'>;
name: string;
urls: Glob[];
version?: number;
}
export declare type Duration = string;
export declare interface Filesystem {
hash(file: string): Promise<string>;
list(dir: string): Promise<string[]>;
read(file: string): Promise<string>;
write(file: string, contents: string): Promise<void>;
}
export declare class Generator {
readonly fs: Filesystem;
constructor(fs: Filesystem, baseHref: string);
process(config: Config): Promise<Object>;
}
export declare type Glob = string;