move cache.js into lib