MiniProfiler "Writing to Response" takes a long time

I’ve just added MiniProfiler to an internal CMS site to diagnose some rather lengthy load times for pages. I’ve done some tweaking already, but one thing that I can’t figure out is why there is a very long “Writing to Response”. My pages aren’t large (<80kb) and this is running a local network, so I can’t imagine its a network bandwidth thing.

Can someone explain what the “Writing to Response” metric is in MiniProfiler, and if there is any general guidance or advice to improve it?

The “Writing to Response” is the time it takes to serialize the Response DTO, write to the response and flush/close the response stream. For Razor / HTML responses it also includes the entire page rendering, including rendering any layout templates/partials/etc. So anything you can do to reduce execution logic will help.

Does it consistently take around 370ms? (note apart from GC pauses, the first call is usually always most expensive).

What are the times like when you add caching?

public object Get(Request request)
    return Request.ToOptimizedResultUsingCache(Cache, "cachedKey", () =>

E.g. if there’s a large difference than the time would be spent executing the page, if there’s not much difference it’s spent writing the response to the response stream.