cache_remote function

Internal function to cache remote file