Your script appears to be broken - one fix involves using the `:` builtin:
But, a different technique is required since these variables need to be exported, as you mention.
Under that, it would be an improvement to make the script idempotent, quote the directories, and use lowercase variable names:
mkdir -p "$cache_dir" ...
This blog appears near the top of search results, so I think other people will benefit from these improvements.