Response accumulating Web Filter running into performance issues...

I have come across this specific issue couple of times now.

A response accumulating web filter (such as WebResponseModifier with the ISA 2004 SDK), does the following.

1. Accumulates resoponse to client in SF_NOTIFY_SEND_RAW_DATA notification.
2. In SF_NOTIFY_END_OF_REQUEST notification, the filter writes modified or unmodified response to client using WriteClient.
3. WriteClient takes a long time to complete. This is often seen when WriteClient is used to write HTTP status line and headers.

Note: MSDN docs on WriteClient confirm that web filters may run into performance issues with WriteClient. Please refer the following for more information.

Best Practices:

In IIS ISAPI, it is recommended NOT to use WriteClient for writing status line and headers but to use ServerSupportFunction.  This is because IIS does not detect that the response to client includes headers (which may result in IIS not correcting / erroring out if the response HTTP message is not formatted correct), if WriteClient was used.

In a similar way, the above ISA WriteClient performance issue can be resolved by using ServerSupportFunction instead. This of course adds additional couple of lines of code to your solution, however this is a cleaner and optimal way of writing response to client.

More info on ServerSupportFunction in ISA SDK is available at

Example code snippet:

char szHeaders [1024] = "Cache-Control: no-cache, no-store\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: 228\r\nServer: Microsoft-IIS/6.0\r\n\r\n";

pfc->ServerSupportFunction(pfc, SF_REQ_SEND_RESPONSE_HEADER, (PVOID) "200 OK",  (ULONG_PTR) szHeaders, NULL);

As you can see szHeaders is for adding any additional headers to the response.

Note: Do not add \r\n at the end of 200 OK (status).