Reset to default
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
A solution based on CloudFront configuration:
Go to your CloudFront distribution, under the “Behavior” tab and create a new behavior.
Specify the following values:
- Path Pattern: index.html
- Object Caching: customize
- Maximum TTL: 0 (or another very small value)
- Default TTL: 0 (or another very small value)
Save this configuration.
CloudFront will not cache
If you never want
index.html to be cached, set the
Cache-Control: max-age=0 header on that file only. CloudFront will make a request back to your origin S3 bucket on every request, but it sounds like this is desired behavior.
If you’re wanting to set longer expiry times and invalidate the CloudFront cache manually, you can use a
/* as your invalidation path (not
/ as you have mentioned). This can take up to 15 minutes for all CloudFront edge nodes around the world to reflect the changes in your origin however.
Here is the command I ran to set cache-control on my index.html file after uploading new files to s3 and invalidating Cloudfront:
aws s3 cp s3://bucket/index.html s3://bucket/index.html --metadata-directive REPLACE --cache-control max-age=0 --content-type "text/html"
It’s much better to run an invalidation for index.html on every release than to defeat Cloudfront’s purpose and serve it (what is basically an entrypoint for your app) from S3 every single time.