Skip to content

Set Cache-Control for non-cacheable resources #4461

@jamesarosen

Description

@jamesarosen

Background

apollo-server@2.10.0

When cacheControl.defaultMaxAge == 0 and a resource does not include the @cacheControl directive, apollo-server returns no Cache-Control header.

RFC7231, §6.1 says,

Responses with status codes that are defined as cacheable by default (e.g., 200, 203, 204, 206, 300, 301, 404, 405, 410, 414, and 501 in this specification) can be reused by a cache with heuristic expiration unless otherwise indicated by the method definition or explicit cache controls [RFC7234]; all other status codes are not cacheable by default.

Some proxies (including CDNs) choose not to cache responses with no cache-control header. Others do.

Expected Outcome

apollo-server returns a Cache-Control header for all responses. One possible default would be max-age=0, no-store.

See Also

Metadata

Metadata

Assignees

No one assigned

    Labels

    🧬 cache-controlRelates to cache directives, headers or packages.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions