Return-Path: Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: (qmail 49847 invoked from network); 5 Jan 2011 13:46:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Jan 2011 13:46:53 -0000 Received: (qmail 13520 invoked by uid 500); 5 Jan 2011 13:46:53 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 12189 invoked by uid 500); 5 Jan 2011 13:46:50 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 12049 invoked by uid 99); 5 Jan 2011 13:46:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jan 2011 13:46:49 +0000 X-ASF-Spam-Status: No, hits=2.5 required=10.0 tests=HTML_FONT_FACE_BAD,HTML_MESSAGE,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jmarantz@google.com designates 74.125.121.67 as permitted sender) Received: from [74.125.121.67] (HELO smtp-out.google.com) (74.125.121.67) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jan 2011 13:46:41 +0000 Received: from wpaz33.hot.corp.google.com (wpaz33.hot.corp.google.com [172.24.198.97]) by smtp-out.google.com with ESMTP id p05DkKWZ011179 for ; Wed, 5 Jan 2011 05:46:21 -0800 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1294235181; bh=idnpGr2ZhIIQff0RE3eQbATReEw=; h=MIME-Version:From:Date:Message-ID:Subject:To:Content-Type; b=ls0aQYMr5Caf0CsoZgGpUPya1Eayv4y6ORetDHkF3CqVveLvtEH4l1lt368rRCw9o JXgFAI6R2hJdn8SEgNBIg== Received: from iyj18 (iyj18.prod.google.com [10.241.51.82]) by wpaz33.hot.corp.google.com with ESMTP id p05DkJZH002526 for ; Wed, 5 Jan 2011 05:46:19 -0800 Received: by iyj18 with SMTP id 18so15912318iyj.26 for ; Wed, 05 Jan 2011 05:46:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=beta; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=PzU0JlokxXbi881K0JakzniuuZRu7D6W8dT7eDu9+cg=; b=OB0/6sa8FFEC+6G9l//HrENLDRjyViJllSgkaEipKqVAbXO+XfBRZudr+10KdpmOwN UqOzM2TvOhZllMa+F+uQ== DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=mime-version:from:date:message-id:subject:to:content-type; b=UPm8cbWo9pgn9QUM9romexIn7nPTVKOqEKvrEhBCbhBXpU3Orh8NAQBiHaexwb471s 1VuYUWsSSrmLDqRPuNlQ== Received: by 10.231.19.131 with SMTP id a3mr23055427ibb.85.1294235177773; Wed, 05 Jan 2011 05:46:17 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.40.11 with HTTP; Wed, 5 Jan 2011 05:45:57 -0800 (PST) From: Joshua Marantz Date: Wed, 5 Jan 2011 08:45:57 -0500 Message-ID: Subject: Help trying to figure out why an output_filter is not called. To: modules-dev@httpd.apache.org Content-Type: multipart/alternative; boundary=00221532cba406ec6c0499199c79 X-System-Of-Record: true X-Virus-Checked: Checked by ClamAV on apache.org --00221532cba406ec6c0499199c79 Content-Type: text/plain; charset=ISO-8859-1 One of the improvements mod_pagespeed is supposed to do to sites is extend the cache lifetime of their resources indefinitely by including a content hash in the URL. This is working well for a large number of sites, but I encountered one today where it does not work. To accomplish the cache extension, overriding any wildcarded or directory-based expire settings a site admin has set for their resources, mod_pagespeed inserts two output filters. The first one does the HTML rewriting: ap_register_output_filter( kModPagespeedFilterName, instaweb_out_filter, NULL, AP_FTYPE_RESOURCE); When instaweb_out_filter runs, it makes this transformation: before: after: The rewritten resource, foo.js.pagespeed.ce.HASH.js, is served by a hook: ap_hook_handler(instaweb_handler, NULL, NULL, APR_HOOK_FIRST - 1); Knowing that mod_headers will later override Cache-Control, which we don't want, our hook serves the .js file with our own header: X-Mod-Pagespeed-Repair: max-age=31536000 We a second output filter, to repair it: // We need our repair headers filter to run after mod_headers. The // mod_headers, which is the filter that is used to add the cache settings, is // AP_FTYPE_CONTENT_SET. Using (AP_FTYPE_CONTENT_SET + 2) to make sure that we // run after mod_headers. ap_register_output_filter( InstawebContext::kRepairHeadersFilterName, repair_caching_header, NULL, static_cast(AP_FTYPE_CONTENT_SET + 2)); This is added into the filter chain whenever we want to extend cache: apr_table_add(request->headers_out, "X-Mod-Pagespeed-Repair", cache_control); ap_add_output_filter("X-Mod-Pagespeed-Repair", NULL, request, request->connection); When working properly, this header is removed from request->headers_out by repair_caching_header(): const char* cache_control = apr_table_get(request->headers_out, "X-Mod-Pagespeed-Repair"); if (cache_control != NULL) { SetCacheControl(cache_control, request); apr_table_unset(request->headers_out, kRepairCachingHeader); } Where SetCacheControl also makes the Expires header consistent, etc. While this approach is complex, I've never seen it fail until today, on the site http://law.thu.edu.tw/main.php . On that site, the "X-Mod-Pagespeed-Repair" header is visible (it should have been removed) and the Cache-Control header has the value set from the conf files (public, max-age=600). So on this server, the repair_caching_header filter is not being run, despite having been programatically inserted by our code in the same place where we add " X-Mod-Pagespeed-Repair" header. What might be going wrong in his server to cause this to fail? Could some other filter be somehow finding our filter and killing it? Or sending the bytes directly to the network before our filter has a chance to run? Thanks! -Josh --00221532cba406ec6c0499199c79--