title: is it not good to use cacheStorage outside serviceWorker ?why?
body: <p>In the <a href="https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage</a> page, it tell us that:</p>
  
  <blockquote>
    <p>The CacheStorage interface represents the storage for Cache objects. It provides a master directory of all the named caches that a ServiceWorker, other type of worker or window scope can access (you don't have to use it with service workers, even though that is the spec that defines it) and maintains a mapping of string names to corresponding Cache objects.</p>
  </blockquote>
  
  <p>so, i want to know.Is it better to use cacheStorage in ServiceWorker than in Window scope? why?</p>
  
  <p>As nobody answer that, i want to share what i think.</p>
  
  <p>In my opinion, there are several advantages.</p>
  
  <p>First of all, serviceWorker is handled by another thread, which make it more efficient.</p>
  
  <p>The next one, serviceWorker can simply add to old website without changing code, while you have to rewrite the ajax code etc, when you plan to use it in window scope.</p>
  
  <p>The last but not least, you can run this when your page has been shut down.For example, you can put sth into cache when you got the push.</p>
  
  <p>However, it still make me confused. Why the browser allow the window scope to get the permission.Is it a convenient way for us to just write in the main thread? Or, that will bring us some security risk, because when our page has been xss, that hacker can get access to cache?</p>