Add |cache| protocol and make the code more cross-platform