I typically develop my applications with frontend single page application on S3 and backend APIs on a server typically elastic beanstalk (so ELB + EC2). I am confused over what is a good choice to put in front of my ELB & S3 - mainly CloudFront or API Gateway. My main need now is caching and performance (reduced load on servers). Of course costs will be bonus too. Traffic is often limited to a single region/country (Singapore) in my case.
So assuming I want to keep to a single domain, I think I will definately require CloudFront? So CloudFront will have 2 origins S3 and ELB. S3 origin can be configured with a long cache TTL and ELB a shorter one, just to handle spikes. Is this a good idea?
But what if some APIs, especially listing API should not be cached. If I set TTL to 0, it will not cache but my understanding is its slower? How best to handle these?
That said, when do I use API Gateway? Assuming I dont need all that SDK stuff and my current systems are still on ELB/EC2. It seems all it will be in my case, will be a proxy and caching system just like cloudfront?