在AWS Cloudfront中,我们可以通过将文件或目录的路径添加到失效列表中来强制缓存失效。以下是一些示例代码:
aws cloudfront create-invalidation --distribution-id E1234567890123 --paths /example.jpg
aws cloudfront create-invalidation --distribution-id E1234567890123 --paths /example/*
aws cloudfront create-invalidation --distribution-id E1234567890123 --paths /*
请注意,每个AWS Cloudfront分配都有一个限制,即您每月只能免费缓存失效1000个对象。如果您需要更多的缓存失效,您需要支付额外的费用。