I am unable to comment on the previous comment from Nick K9 so quoting here for those who get alarmed by this statement.
That's a very important caveat, thank you Ram! The first 1000 invalidations per month are free. After that it's $0.005 per path. So if your bucket has 1MM objects in it, invalidating
*
will cost you $5,000! Be very careful with this.– Nick K9
This is not true. invalidating /* is the same as invalidating a very specific path. CF charges you by number of invalidations (or paths) not number of urls within that path. So unless you're invalidating each file individually, you will only be charged for one invalidation (0.005$).
When to invalidate /* vs individual paths
- Invalidate /* when you dont care about the cache. You just want to reset everything. Like when you're in a dev or non-prod env.
- Invalidate the individual path or parent path if you need to retain the cache to other paths on the same domain. Example, I have a distribution where i fetch /price and /static/asset. The price endpoint runs expensive queries on by DB and only refreshes once every hour with a job. So it makes sense to retain the cache and only clear the cache to /static/asset when I make a change to the asset. In this case, my origin is not loaded and I set the CF cache policy maxTTL to 60 mins. So CF will automatically fetch data after an hour without the need for invalidation.