Customer would like to know if it is possible to cache API requests in Amazon CloudFront if the app cannot set cache-control headers

0

Is it possible to cache API requests in CloudFront if the application the customer is using cannot set cache-control headers? I can see that content can be cached without these headers, but I am unable to find the answer for API requests specifically.

AWS
질문됨 4년 전550회 조회
1개 답변
0
수락된 답변

API requests are 'just' HTTP requests, so the documentation for CloudFront is applicable to all content, regardless as to whether it is an API, dynamically generated HTML, or static content.

You can configure CloudFront caching using MinTTL, MaxTTL (which will place a minimum/maximum limit provided by the origin) and DefaultTTL (which provides a cache TTL when the origin doesn't specify any). These are configured for each cache-behavior, and so it's the same for all URLs matching the bevhavior's path pattern. It also doesn't create or modify the cache-control headers that are passed to the client.

If you need more specific control over of caching (for instance, it is based on a cookie) or you want to actually set the cache=-control header for clients (so they are able to cache downstream) then you could use origin-facing Lambda@Edge to set cache-control before it returns through the cache.

AWS
전문가
답변함 4년 전
profile picture
전문가
검토됨 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠