Update the cache in the middleware.