W3C home > Mailing lists > Public > www-lib@w3.org > January to March 2000

Using the cache with deflated responses

From: James Gallagher <jimg@dcz.dods.org>
Date: Wed, 15 Mar 2000 12:04:35 -0800 (PST)
Message-ID: <14543.60627.308267.677151@dcz.dods.org>
To: www-lib@w3.org

I'm having trouble getting the cache to work with documents that are
compressed. That is, when the cache stores a document whose Content-Encoding
is `deflate', the compressed document is stored in the cache. However, when
the document is subsequently retrieved from the cache it is not decompressed.
I'll append the calls I'm using to initialize the library. 

Has anyone tried using the cache in conjunction with compressed responses?
Does anyone know what I'm doing wrong?

Thanks in advance,

Library init code:

    // Initialize tcp and buffered_tcp transports

    // Set up http and cache protocols. Do this instead of
    // HTProtocolPreemtiveInit(). 
    HTProtocol_add("http", "buffered_tcp", HTTP_PORT, YES, HTLoadHTTP, NULL);
    HTProtocol_add("cache", "local", 0, YES, HTLoadCache, NULL);

    // Initialize various before and after filters. See HTInit.c.

    // Add basic authentication.

    // Add proxy handling here. In HTProfile_newPreem...()
    // HTProxy_getEnvVars() is called. 02/09/98 jhrg
    // Register the default set of converters.
    _conv = HTList_new();

    // Register the default set of transfer encoders and decoders
    HTList *transfer_encodings = HTList_new();

    // Register the default set of content encoders and decoders
    if (accept_deflate) {
#ifdef HT_ZLIB
	HTList *content_encodings = HTList_new();
	HTCoding_add(content_encodings, "deflate", NULL, HTZLib_inflate, 1.0);
#endif /* HT_ZLIB */

    // Register MIME headers for HTTP 1.1

#ifdef GUI
    // Add progress notification, etc.
    HTAlert_add(dods_progress, HT_A_PROGRESS);
    HTAlert_add(dods_error_print, HT_A_MESSAGE);
    HTAlert_add(dods_username_password, HT_A_USER_PW);
    if(!USE_CACHE) {
	// Disable the cache. 
	_cache_enabled = false;
    else {
	// Instead, set up the cache.
	// Remove any stale lock file.  This may not be safe if multiple
	// people are using the same cache directory at once.
	tempstr = new char[strlen(cache_root)+7];
	strcpy(tempstr, cache_root);
	strcpy(tempstr+strlen(cache_root), "/.lock");
	tempstr[strlen(cache_root)+6] = (char)0;
	_cache_root = new char[strlen(cache_root)+1];
	strcpy(_cache_root, cache_root);
	if(HTCacheInit(cache_root, MAX_CACHE_SIZE) == YES) {
	    if(IGNORE_EXPIRES) HTCacheMode_setExpires(HT_EXPIRES_IGNORE);
	    else HTCacheMode_setExpires(HT_EXPIRES_AUTO);
	    _cache_enabled = true;
	else {
	    // Disable the cache. 
	    _cache_enabled = false;
    if (www_verbose_errors)
    // Add our own filter to update the history list.
    HTNet_addAfter(http_terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);

    // We add our own parsers for content-description and server so that
    // we can test for these fields and operate on the resulting document
    // without using the stream stack mechanism (which seems to be very
    // complicated). jhrg 11/20/96
    HTHeader_addParser("content-description", NO, description_handler);
    // Added DODS server header because `Server:' is used by Java. We check
    // first for `XDODS-Server:' and use that if found. Then look for
    // `Server:' and finally default to 0.0. 12/16/98 jhrg
    HTHeader_addParser("xdods-server", NO, server_handler);
    HTHeader_addParser("server", NO, server_handler);

    // Add xdods_accept_types header. 2/17/99 jhrg
    // Add Cache-Control header. Use this to suppres caching of compressed
    // data reqeusts which, for some reason, are broken. 12/1/99 jhrg
Received on Wednesday, 15 March 2000 15:04:47 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:35 GMT