Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between max-age=0 and max-age=-1 in Cache Control?

What's the difference in browser behavior between two headers Cache-control: max-age=0 and Cache-control: max-age=-1?

If the browser receives max-age=0, it will revalidate cache immediately. If the browser receives max-age=10, it will revalidate cache after 10 seconds. What's browser behavior with max-age=-1? Is it the same like with max-age=0? If yes, why we need both?

like image 983
Vladyslav Svichynskyi Avatar asked Nov 01 '25 08:11

Vladyslav Svichynskyi


1 Answers

max-age takes an argument that matches delta-seconds:

The delta-seconds rule specifies a non-negative integer, representing
time in seconds.

  delta-seconds  = 1*DIGIT

max-age=-1 is therefore not a valid directive, and the specification doesn't define an interpretation. The spec suggests:

Caches are
encouraged to consider responses that have invalid freshness
information to be stale.
like image 85
Joe Avatar answered Nov 03 '25 09:11

Joe