Fix for bug #18834
Also do not truncate cache file if it is a symlink