If you want to invalidate selected files but your users don't necessarily access every file on your origin, you can determine which files viewers have requested from Cloud Front and invalidate only those files.
If your Cloud Front distribution triggers a Lambda function on viewer request events, and if the function changes the URI of the requested file, you must invalidate both URIs to remove the file from Cloud Front edge caches: If you configured Cloud Front to forward cookies to your origin, Cloud Front edge caches might contain several versions of the file.
If you'll want to update your files frequently, we recommend that you primarily use file versioning for the following reasons: For more information about file versioning, see Updating Existing Files Using Versioned File Names.
If you want to invalidate multiple files such as all of the files in a directory or all files that begin with the same characters, you can include the wildcard, see Invalidation paths.
When you invalidate a file, Cloud Front invalidates every cached version of the file regardless of its associated cookies.
You can't selectively invalidate some versions and not others based on the associated cookies.You can submit a specified number of invalidation paths each month for free.