aspnet/ResponseCaching

Check response headers on write to preserve middleware order consistency

JunTaoLuo opened this issue · 1 comments

Ran into this issue in aspnet/BasicMiddleware#199. Currently checking the response headers is triggered either by the OnStarting callback which is called when the first write to the body occurs, or when the next middleware returns. This however will not work if the previous middleware buffers the response so no write occurs but modifies the headers on write.

The proposal is to check the response headers relevant to response caching on write as well as the current triggers. This will guarantee that the behaviour will match the middleware order.

If you check on write and on unwind then you should not need OnStarting anymore.