Service Employee Response Cache Headers

I am trying to figure out how a working service works regarding cache headers in responses. Now I have implemented a couple of service workers, but I never had to worry about caching headers, about how long I need to cache files, etc. I am currently implementing it on a corporate website where this material really matters.

Basically when using an employee an http cache is fully cached?

Should I then create a framework to handle resource expiration / revocation, such as the http cache that was used for us? Or am I saying trash?

It would be very helpful if someone could clarify this. I see that there are 3 possible scenarios:

AND). Network request => Service employee fetch => (browser cache?) <=> Server

AT). Network request <=> (browser cache?) <=> Service selector <=> Server

WITH). Network request => Service selector <=> Server

I tested this locally and it seems like C). is the correct implementation where the developer sacrificed a cache / length header paragraph for management.

I am fine with this, I just want it to clear up before I run away and create the basis for reading and observing the caching headers in the worker.

+6
source share
2 answers

A) This is the right model. If a service employee manages the page, all network requests will trigger a fetchservice employee event handler before accessing the browser or network cache.

, , , fetch() cache.add()/cache.addAll(), cache.addAll() "" . , .

, , .

https://jakearchibald.com/2016/caching-best-practices/, , , , .

+7

, . API- Fetch , HTTP- .

, no-store, HTTP-. force-cache, , :

fetch("some.json", {cache: "force-cache"})
  .then(function(response) { /* consume the response */ });

default. . , .

Fetch Standard, Request.cache MSN MDN .

+1

Source: https://habr.com/ru/post/1670085/


All Articles