简体   繁体   English

Service Worker 将文件存储在内容缓存文件中,内容长度为:0

[英]Service Worker stores files in Content Cache files with content-length: 0

While developing a PWA, I'm using a service worker to download and store files in a cache.在开发 PWA 时,我使用服务工作者来下载文件并将其存储在缓存中。 I noticed all text resources (json, js, css, html) all had content-length 0 as they were not being cached.我注意到所有文本资源(json、js、css、html)的内容长度都为 0,因为它们没有被缓存。 While all other files (images, sounds, fonts) had valid content lengths.而所有其他文件(图像、声音、字体)都具有有效的内容长度。

I'm using Chrome 89.0.4389.114.我正在使用 Chrome 89.0.4389.114。

The only common point I noticed was the Accept-Encoding: gzip so I decided to turn compression off.我注意到的唯一共同点是Accept-Encoding: gzip所以我决定关闭压缩。 And now it is working.现在它正在工作。 All files have a non 0 length.所有文件的长度都不是 0。

Workaround:解决方法:

I'm using Spring Boot on the server side, so to turn it off, you need to set a property to false.我在服务器端使用 Spring Boot,所以要关闭它,您需要将一个属性设置为 false。

server.compression.enabled=false

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM