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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Instrument, monitor, fix: a hands-on debugging session

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️