On Sun, Mar 20, 2011 at 05:09:53PM +0100, Eus wrote: > Hi! > > On Sun, 2011-03-20 at 17:01 +0100, Eus wrote: > > > On Sun, 2011-03-20 at 15:50 +0000, Mark Hindley wrote: > > > > > > I suspect it appeared as the CURLOPT_FOLLOWLOCATION was not set. > > > But, if it is possible, I want to have a long-term solution as well. > > > > What semantic does 404 have in apt-cacher? Does the semantic allow for > > not using cached header in case apt-cacher gets 404 referring to the > > above scenario where "apt-get update" probes for non-existent files? > > If suppose CURLOPT_FOLLOWLOCATION was set when the wireless connection > had been disconnected, then would apt-cacher have cached the login page > of the hotspot provider?
Yes, I suspect so, but presumably with a 200 status and that would have been returned to the apt-get/aptitude client which would not be happy! > If that is the case, will apt-cacher return the cached login page when > apt-cacher gets 404 during the normal non-existent file probe of > "apt-get update"? Again, I think so. apt-cacher would go into its 'offline' mode and do the best it can with cached files. I can't think of a way for me to test either of those scenarios without your setup. Could you do it and check the behaviour is as expected Could you try this patch as well which should check that the cached status is still valid. Mark commit 0f4dd6f8f220767ce9323c988b7b8f744e405e3a Author: Mark Hindley <m...@hindley.org.uk> Date: Sun Mar 20 16:34:25 2011 +0000 Check result of HEAD matches status of cached header matches else, refresh diff --git a/apt-cacher b/apt-cacher index 8d83af9..77aaf8a 100755 --- a/apt-cacher +++ b/apt-cacher @@ -601,9 +601,9 @@ sub handle_connection { } else { # use HTTP timestamping/ETag - my ($oldmod,$newmod,$oldtag,$newtag,$testfile); + my ($oldmod,$newmod,$oldtag,$newtag,$oldstat,$testfile); my $response = ${&libcurl($host, $uri, undef)}; # HEAD only - if($response->is_success) { + if($response->is_success || -f $cached_head) { $newmod = $response->header('Last-Modified'); $newtag = $response->header('ETag'); if(($newmod||$newtag) && open($testfile, $cached_head)) { @@ -619,12 +619,22 @@ sub handle_connection { elsif (/^.*ETag:\s*(.*)(?:\r|\n)/) { $oldtag = $1; } - last if $oldtag && $oldmod; + elsif (/^HTTP\S+\s+(\d+)\s.*(?:\r|\n)/) { + $oldstat = $1; + } + last if $oldtag && $oldmod && $oldstat; } close($testfile); } + + # First check status + if ($oldstat && $oldstat ne $response->code) { + debug_message("Cached header status changed from $oldstat to {$response->code}"); + $cache_status = 'EXPIRED'; + debug_message($cache_status); + } # Don't use ETag by default for now: broken on some servers - if($cfg->{use_etags} && $oldtag && $newtag) { # Try ETag first + elsif($cfg->{use_etags} && $oldtag && $newtag) { # Try ETag first if ($oldtag eq $newtag) { debug_message("ETag headers match, $oldtag <-> $newtag. Cached file unchanged"); } -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org