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

add cache-control headers to kube-apiserver #81946

Merged
merged 1 commit into from
Aug 28, 2019

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Aug 26, 2019

Fixes #81945

/kind bug
/priority important-soon

cache-control headers are now set appropriately.  Only openapi is cacheable if etags match.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 26, 2019
}
}

w.Header().Set("Cache-Control", "private")
Copy link
Member

@liggitt liggitt Aug 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-cache, private

we want private clients to revalidate any cached content as well

Copy link
Member

@liggitt liggitt Aug 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think no-cache, private is reasonable for all requests... that just makes clients verify the etag before using cached content, which they are doing with openapi content already. Other responses which don't include an etag would just make the client refetch.

@liggitt
Copy link
Member

liggitt commented Aug 26, 2019

looks reasonable to me, there are a couple other handler chains that we should add this to

@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 26, 2019
"net/http"
)

// WithCacheControl sets the Cache-Control header to no-cache, if it is for openapi and private otherwise because
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update godoc to drop openapi reference

@liggitt
Copy link
Member

liggitt commented Aug 26, 2019

Boilerplate header is wrong for: /home/prow/go/src/k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/endpoints/filters/cachecontrol.go
Boilerplate header is wrong for: /home/prow/go/src/k8s.io/kubernetes/staging/src/k8s.io/apiserver/pkg/endpoints/filters/cachecontrol_test.go

@liggitt
Copy link
Member

liggitt commented Aug 26, 2019

/approve

lgtm after boilerplate is updated

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, liggitt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 26, 2019
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 26, 2019
@deads2k deads2k added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 26, 2019
@deads2k
Copy link
Contributor Author

deads2k commented Aug 26, 2019

/approve

lgtm after boilerplate is updated

fixed, tagged

@deads2k deads2k added this to the v1.16 milestone Aug 27, 2019
@k8s-ci-robot k8s-ci-robot merged commit 8af33f9 into kubernetes:master Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kube-apiserver responses should not be cached
3 participants