add cache to middleware