Posted by Anuraj on Monday, July 13, 2015 Reading time :1 minute
How it works - Last post was about building a basic middleware. In this implementation, I am reading the content which will be writing back to response, removes whitespace between tags using Regular expressions and the whitespace removed stream I will be writing back to the response.
Here is the code snippet.
And here is the extension method which helps to inject the middleware to the pipeline.
Here is the test results before applying the middleware and after applying middleware. The middleware applied to the MusicStore application.
Without HtmlMinification middleware.
With HtmlMinification middleware.
Without middleware the document took almost 14.67 KB. With the HTML minification middleware it got reduced to 10.04 KB. You can find source code in GitHub. I will be adding the tests for the middleware soon.
Happy Programming :)
What do you think? I would like to hear your thoughts, suggestions, and questions in the comments section below.