Extract local cache middleware

Extract LocalCache Middleware, so it can requires rack dependencies,
without adding rack dependencies to `AS::Cache::Strategy::LocalCache`.
Merge pull request #14179 from arthurnn/14171_backport

[backport] Extract local cache middleware