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