Wordpress LScache Plugin: Easy-to-fix bug with rescanning
Last Updated on: Wed, 15 Apr 2026 00:00:02 In the rescan function in img-optm.php file, there are two queries (the main one, and then the check for continuation) that do this: $q = SELECT distinct b.post_id, b.meta_value FROM $wpdb->posts a LEFT JOIN $wpdb->postmeta b ON b.post_id = a.ID LEFT JOIN $this->_table_img_optm c ON c.post_id = a.ID If an image has 10 thumbnails, it appears 10 times in the img_optm table. The last left join then means you get the same results back in 10x duplicate. For each new thumbnail it detects it then adds 10 new entries into the table. This should be: $q = SELECT distinct b.post_id, b.meta_value FROM $wpdb->posts a LEFT JOIN $wpdb->postmeta b ON b.post_id = a.ID LEFT JOIN $this->_table_img_optm c ON c.post_id = a.ID in both places. This massively speeds up the regeneration process. This is a good catch. It is already improved in latest version. https://github.com/litespeedtech/lscache_wp/blob/master/src/img-optm.cls.php#L1190 Im not seeing the fix at your link, but hope to see it in the next version.
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference