Search code examples
cachingcdnamazon-cloudfront

API response non static fields and AWS Cloudfront caching


For an API I'm currently building I'm including timestamp and a unique requestId (uuid) for every service response delivered to the client e.g:

"requestId": "bf0c66fa-0f1c-406c-9ee0-48ff73b8c5ee" "timestamp": "2017-11-03T23:57:40.141Z"

The API sits behind AWS CloundFront.

The API delivers mostly static contents and we'd like the majority of requests to hit the CDN cache rather than the API itself.

Could the varying field values for requestId and timestamp have any undesired side effects when it comes to caching?


Solution

  • No, varying the content will not have an impact on caching.

    CloudFront does not examine the content or make caching decisions based on it. It's only interested in the Cache-Control headers and the TTLs you've defined in the relevant Cache Behavior settings.

    If you are using CloudFront to cache the responses, then the requestId and timestamp will of course be the same each time a response is returned from the cache, rather than being sent to the origin.