Added hopefully working cache code in cache.js; will need to be merged into another file at some point probably