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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ