serverless icon indicating copy to clipboard operation
serverless copied to clipboard

Feature: Add CacheControl to cors configuration to allow for OPTIONS caching in CloudFront

Open reedyrm opened this issue 8 years ago • 0 comments

This is a Feature Proposal

Description

There is support for the maxAge header which is used by the browser to cache OPTIONS request. In addition to this, I would like to cache my OPTIONS response in CloudFront to remove the extra retrieval from API Gateway.

By default, when cors: true is set the cache-control header would not be present. I think it would be an advanced field that the user would have to specifically override like

cors:
  cacheControl: 'max-age=600'

I could get this change in pretty quickly as a PR if the structure is okay with everyone.

Additional Data

There is currently a workaround where I could set the DefaultTTL on CloudFront, but there are other GETs that don't have a Cache-Control header passed back and I don't want them to get that DefaultTTL.

reedyrm avatar Sep 24 '18 13:09 reedyrm