Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a resource Cache-Control HTTP header to be private #3543

Merged

Conversation

renaudclosset
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tickets
License MIT
Doc PR

This change allows to mark a resource as "private" in the cache headers, to avoid having it being cached by shared caching services (Varnish, etc.)

Example:
User resources (/api/user/xxx) may contain sensitive information that cannot be controlled fine-grained enough with a Vary-header. So these resources should only be cached on the client.

Configuration:

resources:
  App\Entity\User:
    attributes:
      cache_headers:
        public: false
        shared_max_age: 0 # <- this is ignored as not relevant on private resources

@dunglas dunglas merged commit bfba69a into api-platform:2.5 Jul 10, 2020
@dunglas
Copy link
Member

dunglas commented Jul 10, 2020

Good catch, thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants