This is a discussion on Re: Can output filter return "page not found"? - modperl ; I'm actually thinking the same thing. I've been looking for a configuration setting that will just notice that the file isn't there and 404, but I think the fact that there IS a response handler is causing Apache to skip ...
I'm actually thinking the same thing. I've been looking for a
configuration setting that will just notice that the file isn't there
and 404, but I think the fact that there IS a response handler is
causing Apache to skip the check for the existence of the file. Failing
a simpler configuration fix I think there's no choice but to fail early
as you both suggest.
It does seem like a different kind of wasted effort. Now I'm going to
check for the template in an additional handler for each and every
request. Since the majority of requests should be correct this is
wasted cycles for most requests.
Failing out of the output handler wastes the data generation phase, but
that's lightweight for most of this particular site and the percentage
of 404 pages will likely be also.
[found-ratio] * [pre-check-time]
more or less than:
[not-found-ratio] * [data-generation-time]
Fortunately this is just a hobby site so I don't have to care too much.
And if I care, I can always instrument the code to find out the actual
values of the three variables.
I do think that there should be a clear way to return a 404 (or any
other code) from the output filter if desired.
Adam Prime wrote:
> firstname.lastname@example.org wrote:
>> Sounds like something I would *not* do. If you are going to return a
>> 404, why not do it as soon as possible.
>> Generating data only to return a 404 sounds like useless extra work
>> unless you are caching the same data for future requests.
> I agree, if you don't want to much up your data generation code, write
> an Access or Fixup Handler (or any other pre-response phase handler of
> your choice) checks for the existence of the template at that stage. If
> it's not there, 404.