简体   繁体   English

未捕获(承诺)DOMException:超出配额

[英]Uncaught (in promise) DOMException: Quota exceeded

I am trying to see the demo of offline status from the below link and I get DOMException: Quota exceeded. 我试图从下面的链接查看脱机状态演示,但我得到DOMException:超出配额。

https://serviceworke.rs/offline-status_demo.html https://serviceworke.rs/offline-status_demo.html

This error occurs only in chrome. 仅在Chrome中会发生此错误。 It works fine in firefox without error in firefox. 它在Firefox中工作正常,而在Firefox中没有错误。

The error occurs in the install event of the service worker. 服务工作者的安装事件中发生错误。 Code from the service worker in posted below for reference. 来自以下服务人员的代码,以供参考。

 // /serviceworker-cookbook/offline-status/ var CACHE_NAME = 'dependencies-cache'; // Files required to make this app work offline var REQUIRED_FILES = [ 'random-1.png', 'random-2.png', 'random-3.png', 'random-4.png', 'random-5.png', 'random-6.png', 'style.css', 'index.html', 'index.js', 'app.js' ]; self.addEventListener('install', function(event) { // Perform install step: loading each required file into cache event.waitUntil( // Error occurs here... Why??? caches.open(CACHE_NAME) .then(function(cache) { // Add all offline dependencies to the cache console.log('[install] Caches opened, adding all core components' + 'to cache'); return cache.addAll(REQUIRED_FILES); }) .then(function() { console.log('[install] All required resources have been cached, ' + 'we\\'re good!'); return self.skipWaiting(); }) ); }); self.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request) .then(function(response) { // Cache hit - return the response from the cached version if (response) { console.log( '[fetch] Returning from ServiceWorker cache: ', event.request.url ); return response; } // Not in cache - return the result from the live server // `fetch` is essentially a "fallback" console.log('[fetch] Returning from server: ', event.request.url); return fetch(event.request); } ) ); }); self.addEventListener('activate', function(event) { console.log('[activate] Activating ServiceWorker!'); // Calling claim() to force a "controllerchange" event on navigator.serviceWorker console.log('[activate] Claiming this ServiceWorker!'); event.waitUntil(self.clients.claim()); }); 

How to rectify this error? 如何纠正此错误? Is there a way to increase the quota limit in chrome? 有没有办法增加Chrome的配额限制?

EDIT1: 编辑1:
This link says that the Chrome checks quota limit per origin whereas firefox has unlimited quota. 链接表示Chrome浏览器检查每个来源的配额限制,而firefox具有无限的配额。

Is there a way to delete all the files cached from the origin (reset to original state) ? 有没有办法删除所有从原点缓存的文件(重置为原始状态)?

The offline-status_demo downloads merely 700kb and hence can't exceed the 5MB Chrome quota limit on its own. offline-status_demo只能下载700kb,因此不能单独超过5MB的Chrome配额限制。 Unless Chrome Cache is already full - as would be the case if you have too many open tabs. 除非Chrome缓存已满-如果打开的标签过多 ,就会出现这种情况。

Answer: try again in incognito mode. 答:在隐身模式下重试。

I don't think there's a way to increase the quota limit. 我认为没有办法提高配额限制。 You just have to cache fewer files, or maybe use better compression. 您只需要缓存较少的文件,或者使用更好的压缩率即可。

The solution that I can think of based on your code, you can give version to your cache name and then whenever you don't want old assets you can delete the whole cache and keep the new cache. 我可以根据您的代码想到的解决方案是,可以给缓存名称指定版本,然后每当不想使用旧资产时,就可以删除整个缓存并保留新的缓存。 for instance: 例如:

self.addEventListener('activate', function(event) {

  var cacheWhitelist = ['dependencies-cache-**v1**', 'dependencies-2-cache-**v1**'];// Version for your cache list 

  event.waitUntil(
    caches.keys().then(function(cacheNames) {
      return Promise.all(
        cacheNames.map(function(cacheName) {
          if (cacheWhitelist.indexOf(cacheName) === -1) {
            return caches.delete(cacheName);
          }
        })
      );
    })
  );
});

I hope this is what you are looking for. 我希望这是您要寻找的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IndexedDB:未捕获(承诺)DOMException - IndexedDB: Uncaught (in promise) DOMException Uncaught DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'domains' exceeded the quota - Uncaught DOMException: Failed to execute 'setItem' on 'Storage': Setting the value of 'domains' exceeded the quota JavaScript错误:未捕获(已承诺)DOMException - JavaScript Error: Uncaught (in promise) DOMException PWA beforeinstallprompt Uncaught (in promise) DOMException - PWA beforeinstallprompt Uncaught (in promise) DOMException 捕获未捕获(承诺)的DOMException javascript - catching Uncaught (in promise) DOMException javascript 如何修复“Uncaught(in promise)DOMException:play()” - how to fix “Uncaught (in promise) DOMException: play() ” video.play()获取(承诺)DOMException - video.play() get Uncaught (in promise) DOMException 推送路由器时未捕获(承诺)DOMException - Uncaught (in promise) DOMException when pushing router Service Worker 中抛出错误“Uncaught (in promise) DOMException” - Error "Uncaught (in promise) DOMException" thrown in Service Worker 如何解决Uncaught(in promise)DOMException错误? - How to solve Uncaught (in promise) DOMException error?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM