For WordPress website installed with W3 Total Cache (W3TC) plugin which intends to optimize and speed up the delivery of dynamic content to visitors, there may be occasional occurrences of PHP error such as the following:
warning: opendir (home/techjourney/public_html/wp-content/cache/db/options_comments/): failed to open dir: No such file or directory
When W3 Total Cache plugin is disabled, the issue is resolved.
The error is even more prominent and clearly visible if Query Monitor debugging plugin is installed to monitor the database queries, hooks, conditionals and overall performance of the WordPress powered site. In Query Monitor, all call stacks indicate that the error is likely caused by W3 Total Cache plugin, with Util_File.php and/or Cache_File.php the likely culprits.
The issue happens when Database Cache is enabled, and the Database Cache Method is set to Disk. W3TC’s Database Cache attempts to reduce post, page and feed creation time by caching database objects in order to decrease the response time of the site. However, when the Database Cache is set to store on disk filesystem, the options_comments directory does not exist, hence PHP is logging the error.
The missing options_comments directory does not affect the functionality of W3 Total Cache, but if you don’t want to see any error message and want to fix the error, try to change the setting in Performance -> General Settings based on one of the following methods:
- Change the Database Cache Method to non-disk method, such as Opcode: Alternative PHP Cache (APC / APCu), Opcode: eAccelerator, Opcode: XCache, Opcode: WinCache, Memcached or Redis.
- Disable the Database Cache by unchecking the Enable check box.