Questions tagged [cachestorage]

The CacheStorage interface represents the storage for Cache objects. It provides a master directory of all the named caches that can be accessed by a ServiceWorker or other type of worker or window scope.

45 questions
11
votes
1 answer

Chrome shows high cache storage use

I have been analyzing the cache storage use of complex application, when I realized that the stored image or script with certain content-length N actually takes 5N-10N space in the cache storage. Consider this sample: I am requesting image from…
Aleksandr
  • 2,185
  • 2
  • 21
  • 29
9
votes
1 answer

window.caches is undefined in Android Chrome, but is available at Desktop Chrome

I am a bit confused with regards to availability of Caches API on mobile devices. https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage Documentation states this API is available on both service worker scope and window scope. I can clearly…
Sergey Rudenko
  • 8,809
  • 2
  • 24
  • 51
8
votes
1 answer

Service worker won't install when I try to cache xxx.worker.js

I have the following service worker code in my Vue app: main.js if (navigator.serviceWorker) { navigator.serviceWorker.register('/service-worker.js').catch(function() { console.log('Service worker registration failed.'); …
Adam Zerner
  • 17,797
  • 15
  • 90
  • 156
5
votes
2 answers

Cache Storage created by service worker disappears after going offline and refreshing page

I am trying to implement offline capabilities for my web app but I'm experiencing some strange behavior while offline and it's probably something I'm missing since it's reproducible both in Chrome and Firefox. I'll describe below what the sample app…
martinzen
  • 83
  • 2
  • 5
4
votes
0 answers

How to share cacheStorage between Safari and PWA (Standalone mode) in iPadOS 14?

I am trying to share data between Safari and a PWA/Standalone mode "Add to Homescreen" app in iPadOS 14 (not iOS) using cacheStorage. I tried Pooya Estakhri's solution and it worked on iOS 14, but the same code did not work for iPadOS 14, even…
dbii
  • 41
  • 1
3
votes
1 answer

What is the maximum file size using Cache API on mobile browsers

What is the maximum size of content body that you can store in CacheStorage for mobile browsers? Specifically, cache.add(...) below. https://developer.mozilla.org/en-US/docs/Web/API/Cache None of the other answers linked are recent or refer to…
cfbd
  • 980
  • 2
  • 9
  • 21
2
votes
1 answer

Reading from deleted cache

I have this module test: var myCache = await caches.open("test"); // create a new cache await myCache.add(new Request("/index.html")); // page was sucessfully stored await caches.delete("test"); myCache.match("/index.html"); // I still read from…
Jan Turoň
  • 31,451
  • 23
  • 125
  • 169
2
votes
1 answer

Override browser cache in PWA service worker

I am using "caches" to cache in service worker my PWA assets and make it available offline. When I change an asset, specifically a js file, I modify at least one byte in my service worker to trigger its native update: the service worker updates and…
Nillus
  • 1,131
  • 1
  • 14
  • 32
2
votes
1 answer

Can the service worker access browser cache?

I haven't found a clear answer to this but from my experiments the following appears true: Service workers have no access to or control over the traditional browser cache. Is this intended? Are there ways to do this that I haven't discovered…
derpedy-doo
  • 1,097
  • 1
  • 18
  • 22
2
votes
0 answers

cache.match() returns response but no headers

When I'm performing a cache.match(url) I successfully get a response. But the response the cache is giving me has no headers and I can't understand why. When I'm looking into the developer tools and the cache storage, I can see the headers that are…
Sascha Wolff
  • 111
  • 1
  • 13
2
votes
1 answer

Responding to fetch request via cache xor indexedDB

I am trying to have a service worker respond to fetch events depending on the type of request made. For static resources I use cache: // TODO: make cache update when item found const _fetchOrCache = (cache, request) => { return…
Lukas
  • 409
  • 1
  • 5
  • 15
2
votes
0 answers

Angular 6 cache.addAll() not working with zonejs

I'm trying to add files to the Cache storage in an angular 6 cli project but keep getting errors because of zonejs and I can't find out why. The code below works fine if I run in in a typescript project with no other code. The files are added to the…
2
votes
1 answer

Delete cache in edge browser using javascript

I was trying to delete caches using this code async function test () { cacheKeys = await caches.keys(); cacheKeys.map(async cacheKey => { caches.delete(cacheKey); await deleteIndexedDBDatabase(cacheKey); }); } The code…
suraj
  • 432
  • 5
  • 19
1
vote
0 answers

Workbox fails to fetch a cached Network Request when offline. Vary header?

I am having an issue with runtime caching working offline on my PWA. I'm using the VitePWA package, which uses Workbox, in GenerateSW mode to build the service worker. The service worker caches some API responses from a Laravel back-end, to work…
1
vote
1 answer

Cache is building up with each load

I am working on my portfolio website. It is a PWA and there is a service worker. I am caching the index page and all the required assets of the index page using the service worker. But when I actually test it the cache size is building up with each…
1
2 3