How to ignore directories?

I think it should be sufficient to set a global policy which excludes .cache and cache.

kopia policy set --global --add-ignore .cache --add-ignore cache

If you only want to exclude caches under a specific directory do:

kopia policy set /path/to/some/dir --add-ignore .cache --add-ignore cache

All ignore rules are inherited from their parents and global is the ultimate parent. When you do that, it will look for .cache and cache when snapshotting any directory (under global, so all of them) and ignore them. In general there’s usually no need to mess with wildcards or “/”.