docs
docs copied to clipboard
Cache responses in Cloudfront
Cloudfront CDN now sits between the client and our application which means we can start thinking about caching HTTP responses for a snappier user experience.
This PR does a few things to enable HTTP caching.
- Render Login + Signup for all users regardless of them having a session. This one might be contentious! By removing the
probably_authenticatedcheck we can serve up the same cached response for all HTTP requests. A user can still access their dashboard by clicking either of those links once they're logged in. - Set
Cache-Controlheaders:public– this one lets Cloudfront know it's allowed to cache itmax-age- controls how long to cache content. I've set this to 5 minutes whilst testing.must-revalidated- check origin server (our app) to see if content is still fresh using etag
- Remove Rails CSP
noncegeneration 😬- this change removes nonce generation which was causing the Etag header to regenerate for every request - effectively preventing a page from being cached.
- Since our CSP isn't currently being enforced this is pretty harmless but it would be nice to eventually lock down our CSP.
- We should come back around on this once we fix up our CSP for
inline-eval(see https://github.com/buildkite/docs/pull/681) .
- We should come back around on this once we fix up our CSP for
Your Render PR Server URL is https://bk-docs-pr-2077.onrender.com.
Follow its progress at https://dashboard.render.com/web/srv-ch31cnpmbg57g9rkt97g.