API Gateway Caching vs CloudFront

前端 未结 2 1609
说谎
说谎 2021-01-02 03:08

I\'m a bit confused by how API Gateway and CloudFront work together. Ultimately, I want to be able to have a custom header and value be considered part of my cache key. I kn

2条回答
  •  清酒与你
    2021-01-02 03:44

    When you enable caching in API Gateway,

    You can also optionally add,

    RequestPath
    QueryStringParameters
    Http Headers
    

    E.g.,

    http://example.com/api/{feature}/?queryparam=queryanswer [ with header customheader=value1 ]

    Above url gives you option to cache based on,

    Just the URL without PathParameters: http://example.com/api/

    Optionally include PathParameter: http://example.com/api/{feature}/

    Optionally include QueryStrings: http://example.com/api/{feature}/?queryparam=queryanswer

    Optionally include Http Headers: You can either include regular header like User-Agent or Custom headers

    Whatever the caching mode you have in API-Gateway, you can also have it under CloudFront as well.

    Also to clear up the cache, in your http response send Cache-Control: max-age=0

    Hope it helps.

提交回复
热议问题