If it is Windows, you can directly write "C:/Cache/"
If it is Linux, you can directly write "/Cache/", you need to change the permissions of the cache to 777 first, and see what errors are reported. See what errors are reported. Add error_reporting(E_ALL & ~E_NOTICE) to the top of PHP; the relative path is relative to the PHP file where fopen is located, i.e. a.php.
$f = fopen("cache/$filename", 'ab);
If a.php is in folder b in the root directory:
$f = fopen(". /cache/$filename", 'ab);