Does nginx reset cache for URL when requested with header Cache-control: no-cache?

Viewed 98

I haven't found it in the docs, but when I debug I see the following behavior:

  • request resource fist time
  • request resource second time, check that cache returned it
  • update resource
  • request resource third time with header: Cache-Control: no-cache
  • verify that updated resource has been returned
  • request resource fourth time, check that cache returned updated resource

So can one use query with cache-control: no-cache to update cache data?

1 Answers

What exactly do you want to accomplish?

If it was possible to bypass cache by simply issuing a request with this extra header, it'd probably be classified as a bug and a DoS vulnerability. At the very least, it would certainly make less sense as a default when caching is explicitly enabled by the administrator.

However, if bypassing the cache is your intention when the Cache-Control is present in the request, then you could use something like http://nginx.org/r/proxy_cache_bypass together with one of the required http://nginx.org/r/$http_ variables:

proxy_cache_bypass $http_cache_control;
Related