support clearing application code cache
This commit is contained in:
@@ -229,6 +229,23 @@ export function clearMapDataCache(): Promise<void> {
|
||||
});
|
||||
}
|
||||
|
||||
export function clearApplicationCodeCache(): Promise<void> {
|
||||
if (!window.caches) {
|
||||
logger.error('caches API is not supported in this browser');
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
return window.caches.delete(SW_CODE_CACHE_NAME).then(success => {
|
||||
if (success) {
|
||||
logger.info(`cache "${SW_CODE_CACHE_NAME}" cleared successfully`);
|
||||
} else {
|
||||
logger.warn(`failed to clear cache "${SW_CODE_CACHE_NAME}"`);
|
||||
}
|
||||
}).catch(error => {
|
||||
logger.error(`failed to clear cache "${SW_CODE_CACHE_NAME}"`, error);
|
||||
});
|
||||
}
|
||||
|
||||
export function clearAllBrowserCaches(): Promise<void> {
|
||||
if (!window.caches) {
|
||||
logger.error('caches API is not supported in this browser');
|
||||
|
||||
Reference in New Issue
Block a user