title: How do I minify dynamic HTML responses in Spring?
body: <p>Following Google's pagespeed advice I would like the minify the HTML responses of my Spring application. I don't mean GZip, I mean removing comments and whitespace from HTML before it is sent down the wire. </p>
  
  <p>I would like to do this dynamically and not in my templates. My templates contain many comments that are useful but should not be part of the response.</p>
  
  <p>Following is my controller;</p>
  
  <pre><code>@Controller
  public class IndexController {
  
      @GetMapping("/")
      public ModelAndView index() {
          Data data = ....
          return new ModelAndView("index", data);
      }
  }
  </code></pre>