Maybe just resolve a relative CACHE_DIR (against Config::get_self_dir()) and strip that prefix from $filename (which has an absolute path).
I have doubts that anyone is customizing CACHE_DIR and using this plugin, but some minimal effort can be put into improving support.