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
已提問 4 個月前檢視次數 191 次
2 個答案
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
專家
已回答 4 個月前
profile picture
專家
已審閱 2 個月前
  • 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
已回答 4 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南