apex / up

Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS.
https://up.docs.apex.sh
MIT License
8.79k stars 377 forks source link

Cloudfront integration #62

Open tj opened 7 years ago

tj commented 7 years ago

CF isn't the most user-friendly thing but could add an integration to throw that up in front of your up app/site for http caching. Now possible with the regional endpoints.

kaihendry commented 7 years ago

Thought API gateway would do this effectively by default.. ?

tj commented 7 years ago

CloudFront is in front of API Gateway as an implementation detail, but it doesn't actually do http caching. The cache that API Gateway provides is a region-specific local cache, as far as I know you'll get 100% misses from CF.

kaihendry commented 7 years ago

Oh sorry, I'm a bit confused since API gateway's Custom Domain Names gives me a XXXXXX.cloudfront.net URL, but after testing it curl -si https://XXXXXX.cloudfront.net | grep x-cache... yes it's always a miss! :(

So the common practice is to put another CF in front of it? Or just avoid Custom Domain Names and put a CF in front of the invoke URL of the form https://XXXXX.execute-api.$region.amazonaws.com/$MYAPI/ ?

I wonder if the https://aws.amazon.com/certification/certified-developer-associate/ tests this crazy stuff. ;)

j commented 6 years ago

@tj I just ran into this. If I manually set CloudFront in front of my API, will I break future deploys?

tj commented 6 years ago

@j you should be ok! I can't think of any issues there. If I add support in Up directly, it'll likely be opt-in so it shouldn't conflict with anything you have