0

I understand, to some degree, the HTTP(S) response cache-control: headers, and associated controls for caching but the request cache-control: headers? How does a user control his own request headers? If users are using a normal browser, they have no ability to manually tweak any request parameters outside of those the URL itself indirectly generates.

How is request cache-control even a thing? Is it only intended for programmatically generated (curl, wget, JavaScript) HTTP(S) requests? or interaction between caches and origins?

Walt Howard
  • 5,872
  • 1
  • 12
  • 11
  • Does this answer your question? [Force browser to refresh css, javascript, etc](https://stackoverflow.com/questions/11474345/force-browser-to-refresh-css-javascript-etc) – Joe Dec 05 '20 at 04:14
  • Most browsers don't give a lot of direct control to users over cache control. They'll let you clear any local cache, or request a page with caching disabled. The linked question covers the second case; that's pretty much it, without using browser extensions. – Joe Dec 05 '20 at 04:18
  • No. All you're doing there is clearing the local cache. It doesn't necessarily change the request headers. If you flush your cache, the browser is going to fetch the latest material by default anyway just because it doesn't have a local copy and doesn't need a request header, cache-control: no-cache, etc. And just flushing local cache isn't going to stop proxies from returning their cached content without going to the origin. So once again, are request header cache-control directives not intended for use by the browser user? – Walt Howard Dec 06 '20 at 21:00

1 Answers1

0

Most browsers don't give a lot of fine-grained cache control to users. They'll let you clear any local cache, which is purely a local operation. Many will also let you request a page with caching disabled; see Force browser to refresh css, javascript, etc for details.

To give a specific example, in Firefox requesting a page will send headers:

GET /... HTTP/1.1
...

However, if I use 'Reload current page', the request will include cache-control headers to request uncached data from upstream:

GET /... HTTP/1.1
...
Cache-Control: max-age=0
...

Similarly for a resource on that page referenced through <img src...>.

GET /... HTTP/1.1
...
Accept: image/webp,*/*
...
Cache-Control: max-age=0

As you suggest, this isn't fine-grained control; I'm not aware of any browsers that allow anything as complex as choosing the max-age for regular browsing.

However, it is a good example of the general cache-control header interacting with the browser's user-facing functionality.

Joe
  • 23,380
  • 9
  • 61
  • 75