You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Dennis Jacobfeuerborn <de...@conversis.de> on 2011/12/05 03:27:25 UTC

[users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Hi,
I create an output filter and have it configured like this:

FilterProvider testfilter TESTFILTER "%{CONTENT_TYPE} = 'text/html'"
FilterProtocol testfilter change=yes,cache=no
FilterChain testfilter

The filter itself works fine but the problem is that despite specifying 
cache=no which according to the documentation should render the output 
uncacheable when I reload the page I only get a 304 Not Modfied response.

I do not see any headers in the response that actually tell the browser 
that the content is uncacheable.
Any ideas what might be going on here?

Regards,
   Dennis

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Posted by Dennis Jacobfeuerborn <de...@conversis.de>.
On 12/05/2011 08:56 PM, Nick Kew wrote:
> On Mon, 05 Dec 2011 20:33:57 +0100
> Dennis Jacobfeuerborn<de...@conversis.de>  wrote:
>
>
>> Ok, so here is what I found out so far.
>
> Thanks!  Looks like we have some useful information here.
> I'll take a look at the source and see if I can see anything
> that looks like the cause of what you describe.  Please
> bug me if I drop the ball on this!
>
> Can I take it the solution you found is a satisfactory solution
> to your original question?
>
>> ap_register_output_filter_protocol("ADVERT", advert_filter, NULL,
>> AP_FTYPE_CONTENT_SET,
>> AP_FILTER_PROTO_CHANGE|AP_FILTER_PROTO_CHANGE_LENGTH|AP_FILTER_PROTO_NO_CACHE);
>>
>> With this I only get 200 responses as desired.

Yes, this is the best approach I think and it provides the desired result.

Regards,
   Dennis

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 05 Dec 2011 20:33:57 +0100
Dennis Jacobfeuerborn <de...@conversis.de> wrote:


> Ok, so here is what I found out so far.

Thanks!  Looks like we have some useful information here.
I'll take a look at the source and see if I can see anything
that looks like the cause of what you describe.  Please
bug me if I drop the ball on this!

Can I take it the solution you found is a satisfactory solution
to your original question?

> ap_register_output_filter_protocol("ADVERT", advert_filter, NULL, 
> AP_FTYPE_CONTENT_SET,
> AP_FILTER_PROTO_CHANGE|AP_FILTER_PROTO_CHANGE_LENGTH|AP_FILTER_PROTO_NO_CACHE);
> 
> With this I only get 200 responses as desired.


-- 
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Posted by Dennis Jacobfeuerborn <de...@conversis.de>.
On 12/05/2011 06:55 PM, Nick Kew wrote:
> On Mon, 05 Dec 2011 15:56:27 +0100
> Dennis Jacobfeuerborn<de...@conversis.de>  wrote:
>
>>> Just out of interest shouldn't the FilterProtocol directive with cache=no
>>> have the same effect as the flag and if I set the flag in the code can I
>>> remove the directive from the configuration (once cache prevention is
>>> working as intended)?
>
> That's what I'm hoping to establish.  We have a number of possibilities here:
> 1. A bug that affects both no-cache options.
> 2. A bug that affects the version you posted but not the one I'm suggesting.
> 3. Your report is missing something relevant, and consequently misleading.
>
> If (1) then I want to fix it, which means reproducing it first.
> If (3) then hopefully you'll get to the bottom of it, possibly with help.
> If (2) then I'd favour nuking the directive.
>
>> Ok, so I just noticed you were talking about
>> ap_register_output_filter_protocol() and not ap_register_output_filter() so
>> I guess the change above is pretty useless.
>
> Look at the header file.  ap_register_output_filter is from 2.0.  In 2.2
> it's just a #define, with the last argument (proto flags) zero.

Ok, so here is what I found out so far. First I commented out the 
FilterProtocol directive. Then I used the following to register the filter:

ap_register_output_filter_protocol("TESTFILTER", testfilter_filter, NULL, 
AP_FTYPE_CONTENT_SET, AP_FILTER_PROTO_NO_CACHE);

The result was that I still got a 304 response. Then I changed the code to 
this in order to make it more similar to what I expressed with the 
FilterProtocol directive:

ap_register_output_filter_protocol("ADVERT", advert_filter, NULL, 
AP_FTYPE_CONTENT_SET,
AP_FILTER_PROTO_CHANGE|AP_FILTER_PROTO_CHANGE_LENGTH|AP_FILTER_PROTO_NO_CACHE);

With this I only get 200 responses as desired.

The only difference in the response is that in the first case I receive an 
Etag header and in the second case that header is not present.

So I modified the mod_filter code to remove the Etag header in addition to 
the Last-Modified header in the case of NO_CACHE and with that change I no 
longer get a 304 but the expected 200 response.

Then I retested the FilterProtocol directive. I removed the protocol flags 
from the module:

ap_register_output_filter_protocol("TESTFILTER", testfilter_filter, NULL, 
AP_FTYPE_CONTENT_SET, 0);

Then I re-inserted the FilterProtocol directive. The result is that the 
Etag reappears but also no Cache-Control header is sent so I get 304 
responses again. I added debug output in the filter function itself that 
outputs the content of f->frec->proto_flags which is 0x13 which corresponds 
to AP_FILTER_PROTO_CHANGE | AP_FILTER_PROTO_CHANGE_LENGTH | 
AP_FILTER_PROTO_NO_CACHE.
So it seems the flags are set correctly but somehow ignored when the 
headers are supposed to be added/removed.

Regards,
   Dennis

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 05 Dec 2011 15:56:27 +0100
Dennis Jacobfeuerborn <de...@conversis.de> wrote:

> > Just out of interest shouldn't the FilterProtocol directive with cache=no
> > have the same effect as the flag and if I set the flag in the code can I
> > remove the directive from the configuration (once cache prevention is
> > working as intended)?

That's what I'm hoping to establish.  We have a number of possibilities here:
1. A bug that affects both no-cache options.
2. A bug that affects the version you posted but not the one I'm suggesting.
3. Your report is missing something relevant, and consequently misleading.

If (1) then I want to fix it, which means reproducing it first.
If (3) then hopefully you'll get to the bottom of it, possibly with help.
If (2) then I'd favour nuking the directive.

> Ok, so I just noticed you were talking about 
> ap_register_output_filter_protocol() and not ap_register_output_filter() so 
> I guess the change above is pretty useless.

Look at the header file.  ap_register_output_filter is from 2.0.  In 2.2
it's just a #define, with the last argument (proto flags) zero.


-- 
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Posted by Dennis Jacobfeuerborn <de...@conversis.de>.
On 12/05/2011 03:43 PM, Dennis Jacobfeuerborn wrote:
> On 12/05/2011 02:12 PM, Nick Kew wrote:
>> On Mon, 05 Dec 2011 13:11:10 +0100
>> Dennis Jacobfeuerborn<de...@conversis.de> wrote:
>>
>>
>>> The filter inserts a header and a footer in the page from two files. I can
>>> modify these files and don't see an update when I reload but I *do* see an
>>> update when I shift+reload. So the filter definitely gets invoked.
>>
>> Is the filter your own, or supplied by a third-party?
>>
>> If you have access to the source, please check whether it sets the
>> AP_FILTER_PROTO_NO_CACHE flag in ap_register_output_filter_protocol.
>
> I created the filter myself so I changed the registration from
>
> ap_register_output_filter("TESTFILTER", testfilter_filter, NULL,
> AP_FTYPE_CONTENT_SET);
>
> to
>
> ap_register_output_filter("TESTFILTER", testfilter_filter, NULL,
> AP_FTYPE_CONTENT_SET|AP_FILTER_PROTO_NO_CACHE);
>
> This doesn't seem to change anything though. I still get the 304 response
> without any headers that forbid caching.
>
> Just out of interest shouldn't the FilterProtocol directive with cache=no
> have the same effect as the flag and if I set the flag in the code can I
> remove the directive from the configuration (once cache prevention is
> working as intended)?

Ok, so I just noticed you were talking about 
ap_register_output_filter_protocol() and not ap_register_output_filter() so 
I guess the change above is pretty useless.

The question is how/where do I add the ap_register_output_filter_protocol() 
call? Is that something I do in addition to the content filtering I do now 
or does it replace what I'm currently doing i.e. do I turn my resource 
filter into a protocol filter (which doesn't sound right)?

Regards,
   Dennis

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Posted by Dennis Jacobfeuerborn <de...@conversis.de>.
On 12/05/2011 02:12 PM, Nick Kew wrote:
> On Mon, 05 Dec 2011 13:11:10 +0100
> Dennis Jacobfeuerborn<de...@conversis.de>  wrote:
>
>
>> The filter inserts a header and a footer in the page from two files. I can
>> modify these files and don't see an update when I reload but I *do* see an
>> update when I shift+reload. So the filter definitely gets invoked.
>
> Is the filter your own, or supplied by a third-party?
>
> If you have access to the source, please check whether it sets the
> AP_FILTER_PROTO_NO_CACHE flag in ap_register_output_filter_protocol.

I created the filter myself so I changed the registration from

ap_register_output_filter("TESTFILTER", testfilter_filter, NULL, 
AP_FTYPE_CONTENT_SET);

to

ap_register_output_filter("TESTFILTER", testfilter_filter, NULL, 
AP_FTYPE_CONTENT_SET|AP_FILTER_PROTO_NO_CACHE);

This doesn't seem to change anything though. I still get the 304 response 
without any headers that forbid caching.

Just out of interest shouldn't the FilterProtocol directive with cache=no 
have the same effect as the flag and if I set the flag in the code can I 
remove the directive from the configuration (once cache prevention is 
working as intended)?

Regards,
   Dennis

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 05 Dec 2011 13:11:10 +0100
Dennis Jacobfeuerborn <de...@conversis.de> wrote:


> The filter inserts a header and a footer in the page from two files. I can 
> modify these files and don't see an update when I reload but I *do* see an 
> update when I shift+reload. So the filter definitely gets invoked.

Is the filter your own, or supplied by a third-party?

If you have access to the source, please check whether it sets the
AP_FILTER_PROTO_NO_CACHE flag in ap_register_output_filter_protocol.


-- 
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Posted by Dennis Jacobfeuerborn <de...@conversis.de>.
On 12/05/2011 04:06 AM, Nick Kew wrote:
> On 5 Dec 2011, at 02:27, Dennis Jacobfeuerborn wrote:
>
>> FilterProvider testfilter TESTFILTER "%{CONTENT_TYPE} = 'text/html'"
>> FilterProtocol testfilter change=yes,cache=no
>> FilterChain testfilter
>
> FilterProtocol is slightly half-baked: filter modules should tell mod_filter
> their protocol details when they register the filter instead.
>
> But still, the above *should* cause it to set Cache-Control: no-cache
> on requests where the filter is invoked (are you sure it is?)

These are the response headers I get with the request:
Connection	Keep-Alive
Date	Mon, 05 Dec 2011 11:51:13 GMT
Etag	"35d2-2d-432a5e4a73a80"
Keep-Alive	timeout=5, max=97
Server	Apache/2.3.14 (Unix) mod_ssl/2.3.14 OpenSSL/1.0.0-fips DAV/2

On the request itself I see these cache relavant headers:
Cache-Control	max-age=0
If-Modified-Since	Mon, 11 Jun 2007 18:53:14 GMT
If-None-Match	"35d2-2d-432a5e4a73a80"

>> The filter itself works fine but the problem is that despite specifying cache=no which according to the documentation should render the output uncacheable when I reload the page I only get a 304 Not Modfied response.
>
> If your browser sends a conditional request then the server might send a 304
> without reference to any filters.  The cache=no option just sets the header
> when the filter is invoked.

The filter inserts a header and a footer in the page from two files. I can 
modify these files and don't see an update when I reload but I *do* see an 
update when I shift+reload. So the filter definitely gets invoked.

I get the desired behavior when I add the following to the server config:

Header Set Cache-Control "max-age=0, no-store"

The "no-store" is key here and without it I see the 304's again.

>> I do not see any headers in the response that actually tell the browser that the content is uncacheable.
>> Any ideas what might be going on here?
>
> Is anything going on that might cause an internal redirect?
> For example, mod_alias, mod_rewrite, mod_negotiation, any error,
> or anything concerning trailing slashes or directory indexes?
> Or a subrequest, as in SSI?

Not that I know of. This is a new virtual machine that just has the naked 
default apache 2.3.14 installed (not 2.3.15 yet as indicated in the 
subject, I will update that later today).
The DocumentRoot is /var/www/htdocs which contains an index.html with the 
content "<html><body><h1>It works!</h1></body></html>" which apparently 
comes with the apache source.

The directory index is the only thing that might be involved here but I 
also tested this by explicitly calling /index.html with the same result.

So right now the whole setup is pretty much as minimal as it gets without 
any aliases, rewrites, etc. involved.

Regards,
   Dennis

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] FilterProtocol cache=no not working correctly in 2.3.15?

Posted by Nick Kew <ni...@webthing.com>.
On 5 Dec 2011, at 02:27, Dennis Jacobfeuerborn wrote:

> FilterProvider testfilter TESTFILTER "%{CONTENT_TYPE} = 'text/html'"
> FilterProtocol testfilter change=yes,cache=no
> FilterChain testfilter

FilterProtocol is slightly half-baked: filter modules should tell mod_filter
their protocol details when they register the filter instead.

But still, the above *should* cause it to set Cache-Control: no-cache
on requests where the filter is invoked (are you sure it is?)

> The filter itself works fine but the problem is that despite specifying cache=no which according to the documentation should render the output uncacheable when I reload the page I only get a 304 Not Modfied response.

If your browser sends a conditional request then the server might send a 304
without reference to any filters.  The cache=no option just sets the header
when the filter is invoked.

> I do not see any headers in the response that actually tell the browser that the content is uncacheable.
> Any ideas what might be going on here?

Is anything going on that might cause an internal redirect?
For example, mod_alias, mod_rewrite, mod_negotiation, any error,
or anything concerning trailing slashes or directory indexes?
Or a subrequest, as in SSI?

-- 
Nick Kew
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org