This article explains how to identify the cause of an error message that occurs when purging the cache in the Commerce Admin. When you attempt to purge cache through the Admin, you receive the following message:
/app/project-id/pub/media/catalog/product/cache/directory/filename" file can’t be deleted. Warning!unlink(/app/project%20id/pub/media/catalog/product/cache/directory/filename?lang=en): No such file or directory
Adobe Commerce (all deployment methods) 2.3.0-2.3.7, 2.4.0-2.4.2-p1
When you attempt to purge cache through the Admin, you receive an error message.
Steps to reproduce:
Expected result:
You successfully flush Adobe Commerce cache with no errors.
Actual result:
You get the “file cannot be deleted” error.
The error is related to a delay between the time that the cache cleaning operation was initiated and when it was reported as completed.
ls -la pub/media/catalog/product/cache/directory/filename
If you see the following output:
ls: cannot access 'pub/media/catalog/product/cache/directory/filename/': No such file or directory
there was an attempt to clear the files when the operation had already been completed. This is not a bug; it is a messaging concurrency issue that is expected to happen sometimes. There is no issue to troubleshoot.
However, if the output shows that the files are still in the cache, you need to submit a support ticket.