Received: (from majordom@localhost) by hyperreal.org (8.8.5/8.8.5) id HAA08473; Thu, 21 Aug 1997 07:32:51 -0700 (PDT) Received: from gate-isdn.ukweb.com (gate-isdn.ukweb.com [194.152.65.149]) by hyperreal.org (8.8.5/8.8.5) with SMTP id HAA08464 for ; Thu, 21 Aug 1997 07:32:41 -0700 (PDT) Received: from aardvark.ukweb.com [192.168.2.4] by gate-isdn.ukweb.com with smtp (Exim 1.61 #1) id 0x1YI2-0003un-00; Thu, 21 Aug 1997 15:32:46 +0100 Date: Thu, 21 Aug 1997 15:32:32 +0100 (BST) From: Paul Sutton To: new-httpd@apache.org Subject: Re: Redirect to negotiated docs (PR#649) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org On Sun, 17 Aug 1997, Paul Sutton wrote: > On Fri, 15 Aug 1997, Roy T. Fielding wrote: > > >Yeah, good point. The server is configured to content negotiate where > > >there is only one variant to pick from. Kind of like an automatic > > >permanent redirect but without the cache-ability. So presumably Apache > > >could spot the fact that there is only one variant and then not set > > >r->no_cache. > > > > Yes. In fact, I thought it was doing that already. It's crazy not to. > > Multiviews with only a single variant is *not* negotiation. > > Absolutely. Unless someone else volunteers, I'll knock up a patch for > this. Ok, how about this. As a reminder, mod_negotiation marks *all* responses to HTTP/1.0 (and earlier) requests as being uncacheable, unless explicitly told to make them cacheable with CacheNegotiatedDocs. This is to prevent (HTTP/1.0) browsers and proxies caching one variant which may not be the correct one for subsequent requests. The issue is that if you are using mod_negotiation in a trivial way to map (say) requests for index onto index.html *with no other variants*, Apache makes your responses non-cacheable when they probably are safely cacheable. This patch makes responses from mod_negotiation cacheable in the following circumstances: * Variants are found by multiviews (i.e. looking on the disk, rather than reading a .var file) AND * there was only one matching variant found on disk AND * request version is HTTP/1.0 or earlier (responses to HTTP/1.1 clients are not forced to be uncacheable in any cases since HTTP/1.1 requires clients to know enough to determine if a negotiated resource is cacheable). //pcs Index: mod_negotiation.c =================================================================== RCS file: /export/home/cvs/apachen/src/modules/standard/mod_negotiation.c,v retrieving revision 1.53 diff -u -r1.53 mod_negotiation.c --- mod_negotiation.c 1997/07/28 18:23:03 1.53 +++ mod_negotiation.c 1997/08/21 14:25:07 @@ -227,6 +227,8 @@ array_header *accept_langs; /* accept_recs */ array_header *avail_vars; /* available variants */ + int count_multiviews_variants; /* number of variants found on disk */ + int ua_can_negotiate; /* 1 if ua can do transparent negotiate */ int use_transparent_neg; /* 1 if we are using transparent neg */ int short_accept_headers; /* 1 if ua does trans neg & sent short accpt */ @@ -649,6 +651,9 @@ char buffer[MAX_STRING_LEN]; enum header_state hstate; struct var_rec mime_info; + + /* We are not using multiviews */ + neg->count_multiviews_variants = 0; if (rr->status != HTTP_OK) { return rr->status; @@ -809,6 +814,8 @@ new_var = push_array (neg->avail_vars); memcpy (new_var, (void *)&mime_info, sizeof (var_rec)); + + neg->count_multiviews_variants++; clean_var_rec(&mime_info); } @@ -1994,7 +2001,8 @@ /* Otherwise, use it. */ - if (!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001)) + if ((!do_cache_negotiated_docs(r->server) && (r->proto_num < 1001)) + && neg->count_multiviews_variants != 1) r->no_cache = 1; if (na_result == na_not_applied)