Added code to create cache directory if it doesn't exist