httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fred Clift <f...@clift.org>
Subject Re: How can I hook exactly just before the default file handler?
Date Fri, 27 Apr 2012 15:41:18 GMT
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 <nick@webthing.com> wrote:

> On Thu, 26 Apr 2012 14:06:22 -0600
> Fred Clift <fred@clift.org> 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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message