Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8B4EECF05 for ; Fri, 27 Apr 2012 15:41:45 +0000 (UTC) Received: (qmail 68732 invoked by uid 500); 27 Apr 2012 15:41:45 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 68708 invoked by uid 500); 27 Apr 2012 15:41:45 -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 68698 invoked by uid 99); 27 Apr 2012 15:41:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Apr 2012 15:41:45 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.212.45] (HELO mail-vb0-f45.google.com) (209.85.212.45) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Apr 2012 15:41:39 +0000 Received: by vbbfs19 with SMTP id fs19so842694vbb.18 for ; Fri, 27 Apr 2012 08:41:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:x-gm-message-state; bh=Q+fVd/mygfa1IcHqGdsUEpb9mCo0oWTajtQWQYeINsw=; b=H0iZ7ph9nPPiMLSn/zXpKIbe6+2eBJJOABBVdqCm7ik1/q837bakY2V6XJPsnJZgqT 8VW4A7P7i2WvLaRuyTCjW+Qbx1dMBjlG4mmptielKSf/7+w7QIbcfk+qx1AB2NqLXdMU Cxbwcc4eoSWRSlR1RUIjEY0O0ejMmEqvrMKFWuHamq7t0RnDA6WuDphYaz7EmXGsazLl yL2z7SkgM/PT9N3jJMYporHo8Tnd8ETeoyLPFr77m5PcT30U33XGE3YNUXRgf1MK9cnM yYZ26F2Ideni7wUEirwX9V+O+hmQpBvRpWPikQL3AoMbexPOKufVxIAUdY9LByCt58X7 BVCA== MIME-Version: 1.0 Received: by 10.220.35.73 with SMTP id o9mr8450870vcd.74.1335541278244; Fri, 27 Apr 2012 08:41:18 -0700 (PDT) Received: by 10.220.65.75 with HTTP; Fri, 27 Apr 2012 08:41:18 -0700 (PDT) X-Originating-IP: [199.58.199.60] In-Reply-To: <20120427003020.291fe90f@baldur> References: <20120427003020.291fe90f@baldur> Date: Fri, 27 Apr 2012 09:41:18 -0600 Message-ID: Subject: Re: How can I hook exactly just before the default file handler? From: Fred Clift To: modules-dev@httpd.apache.org Content-Type: multipart/alternative; boundary=485b393aaadf78ff1404beaaef4d X-Gm-Message-State: ALoCoQkkHjdABOOKY8d4uAMkIRmpnyDJcQnIyOTOzz9gsSy/KG84sMjHniykN/AVPJl7+0PKWw2H X-Virus-Checked: Checked by ClamAV on apache.org --485b393aaadf78ff1404beaaef4d Content-Type: text/plain; charset=ISO-8859-1 The short version of what I'm trying to do: I have an external caching reverse proxy. I would like fast cache invalidation by watching file-system events for static files (e.g. all jpg files) in a hosted environment that I don't control the content for. I can see filesystem events for all the files I care about - I'll get events for anything that modifies the file, ownership, permissions etc. I would like to map file events to request URLs in apache so that I can notify an off-server cache to invalidate any cached objects. I plan on having an external process hold a large list of recent URL/file mappings as reported by apache (where recent is defined as somewhat longer than the default cache expiry). This process will watch events and send expiry notifications to the cache. If I the mapping isn't perfect, which I know will be the case, then I have two failure modes - I may inadvertently expire some objects early from the cache, or I might miss some object that I'd like to have expired, but which will still expire with some default timeout. As long as I dont have too many of the first, the extra cost on the caching server would be worth the near instant expiry on the cache. So, what I'm really trying to do is map any GET requests that I can to static files on the filesystem. In the general case this is beyond complicated - any administrator can configure things as they choose and life is hard. In my case, I (or someone else where I work) is the administrator and we have enough control over our configuration to be able to this. I'd also like to stash some information in a header of the outgoing response for the proxy to use. Is there a better way to determine what requests may be liked to particular filesystem events? Is there a way at in the logging stage to tell if default_handler thought it was successful versus it having problems (e.g. file permissions)? It seems like I can (mostly) get what I need with an 'almost really last' hook (header) and a logging hook (URL to fiile mapping). All that said - I'm open to alternative ideas on this - I'm new to the apache code base (well, new to the 2.x code base anyway) and I'm just figuring out things. Oh, and by the way, I'm enjoying your excellent book "The Apache Modules Book" - very very helpful. Thanks! Fred On Thu, Apr 26, 2012 at 5:30 PM, Nick Kew wrote: > On Thu, 26 Apr 2012 14:06:22 -0600 > Fred Clift wrote: > > > Hi all, > > > > I see that you can specify in the 2nd and 3rd options of the ap_hook_* > > calls modules that should be before and after your module. The > > documentation states that this controls the sort-order of which modules > > execute when. > > I suspect you're making your problem a whole lot more complex than > it need be. > > > Ideally I'd like to make sure I have a hook after any filename/path > > translation is done so I can add a header with reasonable confidence that > > nothing will twiddle it before it gets to the default file handler. > > A fixups hook would be the usual solution to that kind of requirement. > > I'd > > also like to make sure that no interpreters handled my file. > > That's up to the server admin, not up to any module. If a server > admin sets an interpreter (such as PHP) as handler, that's their > business. > > If your module wants to take control of a request then it can > set its own handler (or unset the handler to get the default). > But then it needs to document that it breaks normal configuration! > > -- > Nick Kew > --485b393aaadf78ff1404beaaef4d--