My website is a static site in S3 and I'm using CloudFront. Since it is a SPA , the origin returns a 404 error on every request but loads the page successfully. To solve this I have created a custom error in "Error page" in CloudFront so that it returns a status 200. (This is what is recommended in most blogs)
This works fine but on every html request I see cache: "Error from CloudFront".
My question is if CloudFront is caching the request or is it always going to the origin?
Would it be better to handle this with a Lambda@Edge? How?
Thanks in advance!
Hi Dmytro, Thanks for yor answer. What time(seconds) is recommend for TTL?
It's hard to say without knowing how dynamic your content is. You may find more information by the link https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/HTTPStatusCodes.html