next up previous
Next: Advertising Banner Rotation Up: Cache Applet Examples Previous: Cache Applet Examples

Logging User Accesses

  One of main reasons many Web servers disable caching is to collect information on who access their documents. Both server and proxy suffer from such practice, as the former has to buy a lot of resources to handle the volume of incoming requests, and the latter has to pay for the Internet traffic. Active cache solves the dilemma by using a log applet.

We have implemented a log applet, whose FromCache method simply writes the client IP address, the date of the access, and the HTTP request to the log object. The applet is assured that the log object will be sent back to the server eventually. The Java code looks like the following:

public static int FromCache(
String User_HTTP_Request,
String Client_IP_Address,
String Client_Name,
int Cache_File,
int New_File) {

int fd = open("logapplet.log", APPEND_ONLY);
int status = lock(fd);
String date = new curtime();
log_to_file(fd, date, Client_Name,
User_HTTP_Request, Client_IP_Address);
status = unlock(fd);
close(fd);

return(0); // 0 means use the cached file
}



Pei Cao
7/22/1998