显示 404 URL 的 CloudFront 报告

CloudFront report showing 404 URLs

我的云端有返回 404 的 URL。一旦我使它们无效,一切都很好。我假设在某个时间点源服务器返回了 404,这是由云端缓存的。

有没有办法生成 CloudFront 报告,显示标记为缺失的 URL? (404s)
有没有办法为新用户创建提醒?

如您所见,CloudFront 默认缓存错误。

404 是否有效 URL?一个常见的问题是作为应用程序的一部分,它在上传/发布之前请求 URL(例如文件)来确定其存在。如果您有缓存层,这显然会适得其反。

Is there a way to generate a CloudFront report showing the URLs that are marked as missing? (404s)

这些将写入 CloudFront logs

Is there a way to create an alert for new ones? You could use CloudWatch Alarms to alert based on 4xx/5xx error rate, but this wouldn't give you granularity into the URIs themselves.

您可以使用 Lambda 函数,该函数在日志传送到您给定的 S3 存储桶时调用,配置为针对 4xx 解析它们,然后向您发送通知 (SNS/SES/etc)

除了上面的@alexjs 回答之外,还可以将 404 缓存周期设置为 0。在我的例子中,这是期望的行为,因为 404 永远不应该发生通常表明服务器问题。