WP SUPER CACHE is one of the most used WordPress plugin for cache, but probably there is a small bug in WP Super Cache homepage refresh configuration. This can explain why so many times I received alerts from clients that can’t find their posts in homepage! So I’ve found/modified/made this few lines of code to force refresh of the homepage. You can simply made a cronjob that calls a php file that remove index.*
files from super cache directory, or you can write a wordpress action called with wp cron
and delete hourly the same files.
Be sure that the directory of your cache is /wp-content/cache/supercache/www.yourdomain.com
:
add_action('init','delete_home_cache_hourly'); add_action('delete_home_cache_hourly_job','delete_home_cache_hourly_function'); function delete_home_cache_hourly_function(){ $dir = $_SERVER['DOCUMENT_ROOT']."/wp-content/cache/supercache/".$_SERVER['HTTP_HOST']."/"; $file = "index.html"; unlink($dir.$file); unlink($dir.$file.".gz"); } function delete_home_cache_hourly(){ if(!wp_next_scheduled('delete_home_cache_hourly_job')) wp_schedule_event (time(), 'hourly', 'delete_home_cache_hourly_job'); }