A system and method for dynamically selecting a level of compression to be
applied to data to be served to a client. The level of compression may be
selected on the basis of one or more factors, such as: the bandwidth of a
communication link between the client and a server, the amount of data
requested by the client, the workload of the server, whether the data are
cacheable, etc. The server can readily obtain information such as the
amount of requested data and the available CPU time on the server. To
determine the bandwidth, the server may conduct a test transfer of a
known amount of data to or from the client, or consult a database
identifying known or expected bandwidths for specific client connections
(or addresses). Based on the selected factor(s), the server dynamically
selects a level of compression for the data.