clear_cache() check if cache dir is writable before opening it

If cache dir is writable by webserver but not by cron user, clear_cache() will fail silently, without raising warnings (and without filling my inbox :) )