-
Notifications
You must be signed in to change notification settings - Fork 265
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 header to static resources to help caching #901
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Hi @nzmsv. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
/ok-to-test |
/test tekton-dashboard-unit-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nzmsv thanks for the PR, adding caching support would be very useful for a lot of use cases.
Since the URLs for the static resources already contain a content-based hash we know that content can be cached long-term without requiring periodic revalidation as in the case of using entity tags or similar approaches. Instead of sending the Etag header in the response, we could set a long max-age on the Cache-Control header and eliminate the conditional requests from the browser.
Something like Cache-Control: public, max-age=31536000, immutable
Would this work for your use case?
Thanks, this is a great idea! I tested the Cache-Control header behind ALB and it works correctly. I updated the PR accordingly. |
Prior to this change putting the dashboard behind ALB broke static resource caching. ALB seems to remove the Date header from the response it proxies, however it obeys explicit Cache-Control headers. Static resources coming from webpack already have a content hash as part of their name so we can already assume each URL points to an immutable resource.
/test tekton-dashboard-unit-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/meow hats
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AlanGreene 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 |
/test tekton-dashboard-unit-tests |
Changes
Prior to this change putting the dashboard behind ALB broke static resource caching. ALB seems to remove the Date header from the response it proxies, however it will obey explicit Cache-Control headers.
Static resources coming from webpack already have a content hash as part of their name so they are already immutable.
Note: the first draft of this PR used the Etag header instead. See the discussion below.
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them: