cloudfront . browser caching

0

i want the browser to keep caching for period of time a cloudfront file i serve with out considering the last modified header and etag . and only after this period of time is over - only then i want to revialidate cloudfront again with the etag or last modifed . is it possible ? and how can i do it?

Ronen
asked 4 months ago205 views
2 Answers
0

yes, you can configure Amazon CloudFront to cache content for a specified period of time without considering the Last-Modified header or ETag. This is achieved by setting the "Minimum TTL" (Time-To-Live) value for your CloudFront distribution.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html

Here are the steps to configure this:

  1. Navigate to CloudFront Console:

  2. Select Your Distribution:

    • Select the CloudFront distribution for which you want to configure caching behavior.
  3. Edit the Cache Behavior:

    • In the "Distribution Settings" tab, navigate to the "Behaviors" section.
  4. Edit the Default Cache Behavior:

    • Select the default cache behavior (or the one relevant to your content) and click on "Edit."
  5. Set Minimum TTL:

    • In the "Object Caching" section, you will find "Minimum TTL." Set the desired value for the minimum time that CloudFront should cache the content without revalidating.
  6. Save Changes:

    • Click on "Yes, Edit" to save the changes to your cache behavior.

Kindly refer also to aws documentations for any doubts :-https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html

profile picture
EXPERT
answered 4 months ago
profile picture
EXPERT
reviewed 2 months ago
  • im talking about the browser validation to cloudfront. u are talking about cloudfront re-validation against its origin ..... i did not mean that ? maybe something like header Cache-Control: max-age=14400 ?

0

Browsers always respect the value of cache headers to manage the lifecycle of local cache objects. CloudFront as a server can not control the client browser directly.

You can consider overwrite these cache header when responding these http header. You can leverage CloudFront response header policy to achieve this feature easily.

For example:

  • Remove Header: Last-Modified
  • Add Header: Cache-Control: max-age=1440

In this way browser respects the headers we crafted, after 1440 seconds, do the re-validation.

profile picture
answered 4 months 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.

Guidelines for Answering Questions