How does billing for invalid file requests in Amazon CloudFront work?
In the Amazon docs they say that
Invalidation Requests No additional charge for the first 1,000 files that you request for invalidation each month. $0.005 per file listed in your invalidation requests thereafter.
开发者_如何学GoDoes it mean that if I use www.cloudfront.net/abc.jpg
1000 times and the image is not there, I will be charged?
A request received by CloudFront for an object that doesn't exist is still a request, so will be charged at whatever cost tier you are currently at. (Requests are cheaper when you have a high volume of them.)
If you try to invalidate an object that doesn't exist, it will still count against your free invalidation quota (and be charged if you go above the 1000/month limit that is mentioned in the docs).
Mike B's comment is correct, a more detailed explanation is as follows:
Amazon CloudFront provides support for Invalidating Objects:
If you need to remove an object from CloudFront edge-server caches before it would expire, you can do one of the following:
Invalidate the object. The next time an end user requests the object, CloudFront returns to the origin to fetch the latest version of the object.
Use object versioning to serve a different version of the object that has a differ ent name. For more information, see Updating Existing Objects Using Versioned Object Names.
[emphasis mine]
That is, this is solely a feature supporting the lifecycle of objects in CloudFront's edge-server caches and does not relate in any way to a HTTP 404 (Not Found) status code.
Consequently you won't be charged for the scenario you describe.
Appendix
In case you might be thinking about using CloudFront invalidation as well now, please be aware of the two related FAQs:
Is there a limit to the number of invalidation requests I can make? - There are no limits on the total number of objects you can invalidate; however, each invalidation request you make can have a maximum of 1,000 objects. In addition, you can only have 3 invalidation requests in progress at any given time. [...] You should use invalidation only in unexpected circumstances; if you know beforehand that your files will need to be removed from cache frequently, it is recommended that you either implement a versioning system for your files and/or set a short expiration period. [emphasis mine]
What is the price of Amazon CloudFront? - [...] You may invalidate up to 1,000 files each month from Amazon CloudFront at no additional charge. Beyond the first 1,000 files, you will be charged per file for each file listed in your invalidation requests. You can see the rates for invalidation requests here.
So the pricing reflects this feature not being intended to be a regular cache control mechanism, rather only for out of band invalidation needs.
精彩评论