-
-
Notifications
You must be signed in to change notification settings - Fork 456
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 custom config for all cloudfront inputs #282
Conversation
So, they way this component does things, there are 4 cloudfront cache behaviors, and my change would (at least for now) only allow for changing the default lambda. It would leave the other cache behaviors alone. Correct me if I am wrong, but this change allows one to cache on any path for all the lambdas. I think that is quite a departure with what I had in mind. At least for now. |
That's correct. My change allows you to pass in custom cloudfront behaviour for any path. That's fair enough. It's totally up to you guys. For my project at least this feature is a necessity. I need to disable caching for user profiles and also pass some custom headers to see if the user is on mobile for some pages. I think these are both common use cases. For what it's worth I think that it's a low risk change. It exposes the knobs for the users who need them and leaves the default behaviour the same as before. It doesn't break the API. |
Hi, any idea about when this pr would be merged? |
@danielcondemarin @barrysteyn can we please have some discussion about this? I think that it's not unreasonable that consumers of this library would want to set different CloudFront configurations for different paths. A major feature of Next 9 is statically generated pages. I think it's a fair assumption that you would want different cache behaviour for these pages than other dynamic pages such as user profiles, or other feed type pages which are frequently updated. Supporting the latest version of Next.js is pointless if you don't allow users of your library to take full advantage of the features that these new versions offer. |
Hi - sorry this has taken me so long to respond. Ultimately, I am happy with your suggestions. But one thing: Read about how Daniel (in the README) defines the 4 caching strategies? I think any alteration to cloudfront must keep those caching logics sacrosanct. |
@barrysteyn hi, yeah we discussed with Daniel about it. |
I've had quite a big think about this and decided that I disagree with you on the 4 caching strategies. Why should the deployment library I use dictate how my site does caching? It doesn't make any sense. What happens if my boss walks in and says "we need to cache this page for 3 months because the government only releases data quarterly and thats non negotiable"? I literally cant use this lib. CloudFront allows you to set up to 25 behaviours so why shouldn't I be able to use up to 25? If there were only 4 logical caching strategies then why wouldn't CloudFront just limit this to 4? Or why would the I really appreciate the library and all the work that you're doing, but I disagree on this. Please excuse my frustrations coming through, but its becoming harder to pull upstream each time I try to sync the fork. |
@stan-sack Apologies I haven't had the time to review this PR. I have been head down looking into other features in the project which are as important. I agree that currently the caching options are not flexible enough. I've added this PR to the top of the todos and hopefully should get to it in the next few days. Thanks for the contrib. and your patience 🙏 |
Thanks for communicating. I completely understand. This isnt urgent. |
@stan-sack Something I've realised is that is possible to set Lambda@Edge origin-response on the default path pattern / cache behaviour. Can we prevent that please? The same way is prevented for origin-request, origin-response shouldn't be allowed to be set by users. The reason for that is that I have plans on using origin-response for upcoming features so can't allow it being overridden. |
that was more difficult than it should have been. I think its ready to go! You might want to pull the error strings out into their own module but I think its OK how it is. |
Right, that's this PR ready to merge 😄 Took a while but is now in a good place for people to try out. |
@stan-sack I've added an example app to the |
Great stuff! 🎉 |
🎉 |
Although won't actually be able to use |
I'll have a look at the PR and nudge the serverless folks to see if we could get it merged 🙂 |
Background
Changes
@serverless/aws-cloudfront
Tests