I have a wired case that I couldn't find an explanation to. using Cache API in the service worker.
When I cache a file from my own origin, the cached size is ok. about 8Kb. When I move the file to CloudFront/S3 the cached size doesn't make sense and inconsistent. between 3Mb to 12MB!!
my service worker fetch function
self.addEventListener('fetch', (event) => {
if (event.request.url === 'https://MyCloudfront.cloudfront.net/api_uploads/vmRevolution/css/mui.css') {
// ---> Cache size will be 3MB -12MB
// if (event.request.url === 'https://myDomain.example/api_uploads/vmRevolution/css/mui.css') {
// ---> cache size will be 8Kb
// if (event.request.url === 'https://localhost/api_uploads/vmRevolution/css/mui.css') {
// ---> cache size will be 8Kb
showLog('file cache');
event.respondWith(
caches.match(event.request).then((cachedResponse) => {
if (cachedResponse) {
return cachedResponse;
}
return caches.open(RUNTIME).then((cache) => fetch(event.request).then((response) =>
// Put a copy of the response in the runtime cache.
cache.put(event.request, response.clone()).then(() => response)));
})
);
}
})
Any ideas why?
When I cache all of my assets the size of the cache gets to crazy size of 600MB - 1GB