简体   繁体   中英

AWS CloudFront will only invalidate entire cache

I want to invalidate the CloudFront cache entry for a specific path, say /api/dict/bob/article/1 , but it has no effect. I've experimented with different wildcards, for instance:

  • /*/1
  • /api/dict/bob/article/*
  • /api/dict/bob/*
  • /api/dict/*

But in the end, the only invalidation that actually removes the object from the cache is the catch-all /*

The path's origin is custom (API Gateway)

Cache policy: Minimum TTL: 60, Maximum TTL:28800, Default TTL: 10800

Cache key:

  • query-strings all
  • cookies: all
  • headers: whitelist (one param)

Update: I managed to invalidate an svg-file from an s3 origin. The api origin requires an x-api-key http-header. Could that make a difference?

I think * can be only in the end. Are you sure it is not a client caching and you waited for the invalidation to finish? It is a slow process, not instant for sure. You can track its progress either on the UI or using the CLI.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

To invalidate files, you can specify either the path for individual files or a path that ends with the * wildcard, which might apply to one file or to many, as shown in the following examples:

/images/image1.jpg

/images/image*

/images/*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM