It may be necessary to clean up a directory from unnecessary data. This often involves "cache" directories. In a Linux shell, you can use various combinations of commands, but a very effective method for cleaning up thousands of files is to use the rsync trick:
mkdir new_directory
rsync -a --delete new_directory/ cache/
Keep the order: the empty directory comes first, the directory to be emptied last. If the arguments are swapped, or new_directory is not empty, rsync deletes or overwrites other data.
From the example, you create a "new_directory," which is, of course, empty, and the directory containing the files to be deleted is "cache."