Update middleware.js to support unique cache key for private api.