Add caching back into server.js

this caching is more correct than the previous caching