Description
It seems the default setup that is generated by the cloudformation template for this project includes a default value for the Cloudfront distribution that has this setting: "Cache Based on Selected Request Headers" set to use the "Accept" header. I believe this is set on line 433 in deployment/serverless-image-handler.template:
"ForwardedValues": {
"Headers" : ["Accept"],
"QueryString": "false",
"Cookies": { "Forward": "none" }
},
Wouldn't this result in a much lower Cloudfront cache hit rate and thus more Lambda invocations? Since each browser can use a different Accept value in their request headers each browser version could potentially generate a different version of the same cached image.
Removing this from our Cloudfront distribution made our Cloudfront cache hit rate jump up to 75-80% from under 50% previously, and significantly lowered the number of Lambda invocation and our overall cost.
Unless this Accept header is needed I think it should be removed from the template as it needlessly increases the cost of using this solution.