Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use Cache-Control header in request?

This page on Cache-Control specifies the following:

Standard Cache-Control directives that can be used by the client in an HTTP request.

I thought that only servers send back information on whether a client should cache a response. Why would a client send a caching information to the server?

like image 531
Max Koretskyi Avatar asked Dec 18 '25 00:12

Max Koretskyi


1 Answers

There may be any number of intermediate proxies between the client and server which do caching. The client can explicitly request explicit caching behaviour from any and all caching entities, things like:

  • max-age - "I don't want a response older than X"
  • no-cache - "I want a fresh response"
  • no-transform - "I don't want it unless it's the original"
  • only-if-cached - "Don't bother the origin server if you don't have it already"

As with all requests, servers have a certain leeway in whether to honour the request or not. Just because a client insists on an uncached response doesn't mean it's necessarily going to get it.

like image 109
deceze Avatar answered Dec 20 '25 18:12

deceze



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!