HTCP and ICP have many common characteristics, although HTCP is broader in scope and generally more complex. Both use UDP for transport, and both are per-request protocols. However, HTCP addresses a number of problems with ICP, namely:
An ICP query contains only a URI, without even a request method. HTCP queries contain full HTTP request headers.
ICP provides no security. HTCP has optional message authentication via shared secret keys, although it isn't yet implemented in Squid. Neither protocol supports encrypted messages.
ICP uses a simple, fixed-sized binary message format that is difficult to extend. HTCP uses a complex, variable-sized binary message format.
HTCP supports four basic opcodes:
Tests for the presence of a cached response
Tells a neighbor to update cached object headers
Tells a neighbor to remove an object from its cache
Monitors a neighbor cache's activity
In Squid, only the TST opcode is currently implemented. This book won't cover the others.
The primary advantage of using HTCP over ICP is fewer false hits. HTCP has fewer false hits because the query messages include full HTTP request headers, including any Cache-Control requirements from the client. The primary disadvantages are that HTCP queries are larger, and they require additional CPU processing to generate and parse. Measurements indicate that HTCP queries are about six times larger than ICP queries, due to the presence of HTTP request headers. However, Squid's HTCP replies are typically smaller than ICP replies.
HTCP is documented as an experimental protocol in RFC 2756. For more information about the message format, see the RFC at http://www.htcp.org or my O'Reilly book, WebCaching.
To use HTCP, you must configure Squid with the enable-htcp option. With this option enabled, Squid becomes an HTCP server by default. The htcp_port specifies the HTCP port number, which defaults to 4827. Setting the port to 0 disables the HTCP server mode.
To become an HTCP client, you need to add the htcp option to a cache_peer line. When you add this option, Squid always sends HTCP messages, instead of ICP, to the neighbor. You can't use both HTCP and ICP with a single neighbor. The ICP port number field actually becomes an HTCP port number, so you need to change that as well. For example, let's say you want to convert an ICP neighbor to HTCP. Here's the neighbor configured for ICP:
cache_peer neighbor.host.name parent 3128 3130
To switch over to HTCP, the line becomes:
cache_peer neighbor.host.name parent 3128 4827 htcp
Sometimes people forget to change the port number, and they end up sending HTCP messages to the ICP port. When this happens, Squid writes warnings to cache.log:
2003/09/29 02:28:55| WARNING: Unused ICP version 23 received from 18.104.22.168:4827
Squid doesn't currently log HTCP queries as it does for ICP queries. HTCP queries aren't tracked in the client_list page either. However, when you enable HTCP for a peer, the cache manager server_list page (see Section 22.214.171.124) shows the count and percentage of HTCP replies that were hits and misses:
Histogram of PINGS ACKED: Misses 5085 98% Hits 92 2%
Note that none of the current Squid versions support HTCP authentication yet.