cachingwebpackbrowser-cacheapplication-cachesw-precache

Application Cache Storage items have empty response?


I'm getting my preactjs website set up with service worker.

Using the Sw-precache-plugin

I'm just looking at the cache items it stores in the Cache Storage, and the entries I expected are all there but they have an empty response.

I checked some other websites with service workers and noticed their entries have a response of "OK".

Just wondering what is the trigger to make a cache response say "OK" rather than blank.

enter image description here

Another example I found where some return OK and others Blank

enter image description here


Solution

  • The "Response" column in Chrome's cache storage viewer is meant to reflect the value of the statusText field of the associated Response object. The traditional status line for a successful response is '200 OK', so 'OK' is the statusText portion of that. You can see this in action by storing a Response with a different statusText, e.g.:

    enter image description here

    Sometimes when there is no 'OK' listed, it's because the Response is opaque, and the statusText isn't accessible. That's the case for those font resources in your second screenshot.

    That being said, I have seen situations in which responses that are not opaque, like those sw-precache-managed entries in your first screenshot, don't have the statusText reflected properly. It might be in those situations that your web server is just responding with '200' status line rather than '200 OK', which would translate to a status of 200 and a statusText of ''. That's a perfectly valid thing for a web server to use for a status line, and as long as the entries are being used successfully, I don't think you need to worry about it.