Cache endpoint responses on a per-principal basis

Previously, any HTTP request to an endpoint that included a principal
would bypass the cache. This prevented authenticated requests from
making use of the cache and its configurable time-to-live.

This commit updates the caching operation invoker to include the
principal, if any, in its cache key. As a result, requests that
include a principal will make use of the cache, potentially returning
the result of a previous invocation of the same endpoint by the same
principal.

Closes gh-19538
This commit is contained in:
Andy Wilkinson
2020-03-13 15:31:41 +00:00
parent ef9960c69f
commit 0315724126
3 changed files with 99 additions and 15 deletions

View File

@@ -406,8 +406,6 @@ The following example sets the time-to-live of the `beans` endpoint's cache to 1
NOTE: The prefix `management.endpoint.<name>` is used to uniquely identify the endpoint that is being configured.
NOTE: When making an authenticated HTTP request, the `Principal` is considered as input to the endpoint and, therefore, the response will not be cached.
[[production-ready-endpoints-hypermedia]]