Skip to content

Do Cache-Control headers added in viewer-response Cloudfront functions change how cloudfront caches the response?

0

Say I have an s3 bucket as a cloudfront origin, and a behaviour that links requests to files from the S3 origin. If I add a viewer response Cloudfront function to this behaviour, and I set a Cache-Control response header in this function, will Cloudfront's caching layer use the information in this new Cache-Control header to determine how long to cache the response? Or will it still use the Cache-Control header set by the origin? I would like to be able to override the caching behaviour using this viewer-response function if possible. If this is not possible, is there another way I can control the caching behaviour based on information in the request?

asked a year ago230 views
2 Answers
1

Hi. You should use origin response behavior for that. Viewer response is controlling only what headers will browser have. In you case you are telling browser on how long it should cache the response

answered a year ago
EXPERT
reviewed a year ago
EXPERT
reviewed a year ago
  • OK.. thanks for the info. On a similar note, if I have a viewer-request function that directly returns a response, does cloudfront cache that response? And if i set a Cache-Control header in that response will that be used by cloudfront? or is that only for the viewer's browser?

0

I think this image explains you question best Enter image description here

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.