W3C home > Mailing lists > Public > www-lib@w3.org > April to June 1999

Re: Cache problem + fix

From: Henrik Frystyk Nielsen <frystyk@w3.org>
Date: Tue, 22 Jun 1999 16:49:28 -0400
To: www-lib@w3.org
Message-ID: <376FF6D8.3DB7E655@w3.org>
To: jose.kahan@w3.org
jose.kahan@w3.org wrote:
> 
> Problem:
> 
> If the libwww cache contains an entry for a document and you PUT the
> document corresponding to this entry, the entry isn't updated. If you
> quit the libwww application and you browse the document, you'll get the
> previous version.
> 
> Fix:
> 
> In HTCache.c, I systematically delete the cache entry whenever doing
> a PUT:

Hmm, that is what the HTCacheCheckFilter() should do in HTCache.c (it is
only done when we have a 2xx code so that we don't delete the cached
entry if the operation doesn't suceed).  

PRIVATE int HTCacheCheckFilter (HTRequest * request, HTResponse *
response,
				void * param, int status)
{
    if (status/100==2 && !HTMethod_isSafe(HTRequest_method(request))) {
        if (status==201) {
	    HTParentAnchor * anchor =
HTAnchor_parent(HTResponse_redirection(response));
    	    if (!anchor) anchor = HTRequest_anchor(request);
	    HTCache_touch(request, response, anchor);
	} else {
	    HTParentAnchor * anchor = HTRequest_anchor(request);
	    HTCache * cache = HTCache_find(anchor);
	    if (cache) {
		if (status == 204)
		    HTCache_updateMeta(cache, request, response);
		else
		    HTCache_remove(cache);
	    }
	    HTCache_touch(request, response, anchor);
	}
    }
    return HT_OK;
}

After the 204 status code is used slightly different now, the check
should also be updated - try this patch to see if it works better:

Index: HTCache.c
===================================================================
RCS file: /sources/public/libwww/Library/src/HTCache.c,v
retrieving revision 2.66
diff -c -r2.66 HTCache.c
*** HTCache.c	1999/03/14 02:01:08	2.66
--- HTCache.c	1999/06/22 20:47:23
***************
*** 1366,1374 ****
  	    HTParentAnchor * anchor = HTRequest_anchor(request);
  	    HTCache * cache = HTCache_find(anchor);
  	    if (cache) {
! 		if (status == 204)
  		    HTCache_updateMeta(cache, request, response);
! 		else
  		    HTCache_remove(cache);
  	    }
  	    HTCache_touch(request, response, anchor);
--- 1366,1381 ----
  	    HTParentAnchor * anchor = HTRequest_anchor(request);
  	    HTCache * cache = HTCache_find(anchor);
  	    if (cache) {
! 		/* 
! 		** If we recieve a 204 and the method is unsafe then we have
! 		** to delete the cache body but not the header information
! 		*/
! 		if (status == 204) {
  		    HTCache_updateMeta(cache, request, response);
! 		    cache->size = 0;
! 		    cache->range = YES;
! 		    REMOVE(cache->cachename);
! 		} else
  		    HTCache_remove(cache);
  	    }
  	    HTCache_touch(request, response, anchor);

-- 
Henrik Frystyk Nielsen, <frystyk@w3.org>
World Wide Web Consortium, MIT/LCS NE43-356
545 Technology Square, Cambridge MA 02139, USA
Received on Tuesday, 22 June 1999 16:49:32 GMT

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