check for null before accessing cache_dir