DEV Community

Pankaj Patel
Pankaj Patel

Posted on

TIL: cache-control is as inconsistent as it can get in different Browsers

Today a colleague started asking questions on cache-control and how to achieve consistent behaviour so that he can control it from Server Side

Then another colleague pointed out a StackOverflow thread where the answer makes sense but raises a question on why do these differences exist?

I got it. Google Chrome ignores the Cache-Control or Expires header if you make a request immediately after another request to the same URI in the same tab (by clicking the refresh button, pressing the F5 key or pressing Command + R). It probably has an algorithm to guess…

I think I still don't understand it completely after this revelation.

I suggested that we can use Service Workers to intercept all requests and implement better caching strategy there.

In response, another colleague pointed out that SWs are not worth the work and the support is inconsistent.

which lead me to here: https://caniuse.com/serviceworkers

caniuse.com_serviceworkers

Which again raises this question what is best approach to control caches from server?

Top comments (0)