-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Chore] Enable caching #11
Conversation
1a02525
to
29b1daf
Compare
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.
Generally LGTM, thanks! Tested on our test application, loading some resources is broken now. See the comment from @puckzxz , that should fix it 🙂
Co-authored-by: Chris <cbock1337@gmail.com>
5d2558e
to
a03d5f4
Compare
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.
Solution: Limit cloudflare worker to only cache request which match the specified routes
Makes sense!
Thanks!
Left a few minor clean up suggestions
Co-authored-by: Lud <swiknaba@users.noreply.github.com>
Co-authored-by: Lud <swiknaba@users.noreply.github.com>
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
Summary
Customise caching in the cloudflare worker script.
This PR sets two Page Rules: Edge Cache TTL and Cache Level (to Cache Everything) using the request url as the cacheKey on the processed request
Edge Cache TTL VS Browser cache Expire TTL here
=> Browser cache TTL
=> Edge Cache TTL
Unfortunately, edge cache TTL would not be reflected in the response header. See here
Regarding html caching
The Cloudflare router by default does not cache html file by default
See here
Setting
cacheEverything
to true to allow html file to be cached by Cloudflare as well.https://developers.cloudflare.com/workers/runtime-apis/request#requestinitcfproperties
TODO
cacheEverything
to true can be dangerous for dynamic pages. Investigate how it affect the current setupReferences