Conditions for caching Response caching middleware page by Microsoft lists conditions that request must meet for caching:
The request must result in a 200 (OK) response from the server.
The request method must be GET or HEAD.
Terminal middleware, such as Static File Middleware, must not process the response prior to the Response Caching Middleware.
The Authorization header must not be present.
Cache-Control header parameters must be valid, and the response must be marked public and not marked private.
The Pragma: no-cache header/value must not be present if the Cache-Control header is not present, as the Cache-Control header overrides the Pragma header when present.
The Set-Cookie header must not be present. Vary header parameters must be valid and not equal to *.
The Content-Length header value (if set) must match the size of the response body.
The HttpSendFileFeature is not used.
The response must not be stale as specified by the Expires header and the max-age and s-maxage cache directives. Response buffering is successful, and the total length of the response is smaller than the configured limit. The response must be cacheable according to the RFC 7234 specifications. For example, the no-store directive must not exist in request or response header fields. See Section 3: Storing Responses in Caches of the RFC document for details. .