Cache-Control: no-cache
from client request makes the response itself non-cacheable
#14120
Open
1 task done
Is there an existing issue for this?
Kong version (
$ kong version
)2.8.1
Current Behavior
When I do
$ curl --silent --dump-header - --header "cache-control: no-cache" --request GET http://localhost:8000/foo-bar/ --output /dev/null HTTP/1.1 200 OK Content-Type: application/json Content-Length: 4556 Connection: keep-alive X-Cache-Status: Bypass
to bypass the cache for the current request, the response for this never gets cached. Which is not what the RFC says. The RFC mentions that the request should not use the stored cache.
This creates a situation where someone wanting to force revalidate a cached object using the
Cache-Control: no-cache/no-store
header fails to do so as kong always bypasses storing the object in the cache.It doesn't look like an expected behavior. At least nginx itself doesn't foce anything like this. I can always add some nginx config like below that'll skip the nginx proxy_cache and refill it based on the response headers.
Expected Behavior
we should not decide if the response is cacheable or not based on the request Cache-Control headers, rather it should only be decided based on the response
Cache-Control
header as the RFC mentions.Also, it should not be tied to the cache_control configuration as well which is used currently for both request and response. If anything there should be a separate configuration for request IMO.
FYI, the existing behavior of the
no-store
directive is correct; as described in the RFCSteps To Reproduce
Just enable proxy_cache in a service/route which works
enable cache_control
curl --silent --dump-header - --request GET http://localhost:8000/foo_bar/ --output /dev/null
gives youcurl --silent --dump-header - --request GET http://localhost:8000/foo_bar/ --output /dev/null
gives youcurl --silent --dump-header - --header "cache-control: no-cache" --request GET http://localhost:8000/foo_bar/ --output /dev/null
gives youcurl --silent --dump-header - --request GET http://localhost:8000/foo_bar/ --output /dev/null
gives youwhich is the previous cached object, not the revalidated one as it was never cached.
The text was updated successfully, but these errors were encountered: