5

What's the​ difference between a HTTP response with Cache-Control: no-cache vs Cache-Control: max-age=0, must-revalidate, proxy-revalidate?

Do browsers treat that as identical?

Pacerier
  • 76,400
  • 86
  • 326
  • 602

1 Answers1

2

In general different Browsers do not behave exactly the same wrt. HTTP cache headers.

One small difference I remember (can't find the source, so I'm not 100% this is the exact behavior description) is that Chrome (afair) treat max-age=0 as if you specified max-age=10 (assuming the behavior difference is small enough, but performance impact is still meaningful).

In any case, here are some other examples of HTTP cache behavior difference between browsers:

  • Some will give preference to HTTP 1.0 Cache header (Pragma), others will give preference to HTTP 1.1 Cache headers
  • Some Browsers (FF + ?) don't honor no-store directive and store data in encrypted cache
  • Some browsers ignore no-cache directive is specified after public, others don't.
  • IE ignores max-age when vary is present.
  • etc.

My overall recommendation would be to use both Cache-Control: no-cache, must-revalidate, proxy-revalidate, pragma: no-cache (HTTP 1.0) and Expires: 0 in order to ensure all browsers do not cache the content with these headers.

Community
  • 1
  • 1
Lior Bar-On
  • 8,250
  • 3
  • 28
  • 41
  • How did you get the info that Chrome treat `max-age=0` as if we specified `max-age=10`? – Pacerier Aug 15 '14 at 17:31
  • I remember this, but I can't find the source. I'll update the answer with a reservation until I find a right source. In any case: I can bring a number of more examples of browsers not behaving the same wrt. HTTP cache headers. – Lior Bar-On Aug 15 '14 at 18:01