RE: rewrite before caching?

2009-03-19 Thread Houser, Rick
Sounds like a badly broken application to me.  If the data is truly
cacheable, the application shouldn't be taking explicit steps to try to
prevent just that.  Depending on what the backend system is, you might
be better off using some kind of a filter to just remove that killCache
parameter in the body text before it gets to the client.  Then, you
don't have to worry about it at all.



Thanks,

Rick Houser
Auto-Owners Insurance
Systems Support
(517)703-2580

-Original Message-
From: Anthony J. Biacco [mailto:abia...@formatdynamics.com] 
Sent: Thursday, March 19, 2009 3:36 PM
To: modules-dev@httpd.apache.org
Subject: rewrite before caching?

I posted this on the users list, but didn't get any help, so I'm hoping
the dev people here can either help or at least explain if what I'm
seeing below is how it's meant to work..

I have a uri with cachebusting in it that looks like this:
/path?killCache=x¶meter1=y%parameter2=z
where x is a unix timestamp used to make sure the url isn't cached by
the browser.

Now though I want to use apache disk caching on this url. Obviously with
the killCache parameters always changing though, this is futile. And I
can't ignore the query string with CacheIgnoreQueryString because
parameter1 and parameter2 are important to the output to the end-user,
so the cache would be inconsistent if I had caching ignore the query
string.

So I decided to rewrite the url to remove the killCache parameter, and
while this rule itself works fine (I'm rewriting to a path not a full
url), it seems the cache check is done before the rewrite.

My rule is:

RewriteCond %{QUERY_STRING}
^killCache=(.+)\¶meter1=(.+)\¶meter2=(.+)
RewriteRule ^/path /path?parameter1=%2¶meter2=%3 [L]

And in the log I see:

 [Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(131): Adding CACHE_SAVE
filter for /path [Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(138):
Adding CACHE_REMOVE_URL filter for /path [Wed Mar 18 12:02:47 2009]
[debug] mod_headers.c(740): headers:
ap_headers_output_filter()
mod_cache.c(639): cache: Caching url:
/path?killCache=x¶meter1=y¶meter2=z
[Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(645): cache: Removing
CACHE_REMOVE_URL filter. 
[Wed Mar 18 12:02:47 2009] [debug] mod_disk_cache.c(962): disk_cache:
Stored headers for URL
http://myhost/path?killCache=x¶meter1=y¶meter2=z
[Wed Mar 18 12:02:47 2009] [debug] mod_disk_cache.c(1051): disk_cache:
Body for URL http://myhost/path?killCache=x¶meter1=y¶meter2=z
cached.

And I get a different cache file stored for every value of the parameter
killCache.

Anybody know a way to get the rewriterule processed before the cache
mechanism? I can rewrite to a full url and the new request will then
pull from cache, but that induces an extra request and an extra log
entry, which I'd like to avoid if at all possible.

Thanx,

-Tony
---
Manager, IT Operations
Format Dynamics, Inc.
303-573-1800x27
abia...@formatdynamics.com
http://www.formatdynamics.com





Re: rewrite before caching?

2009-03-19 Thread Ray Morris
   If you're doing your rewrite in .htaccess, 
it _MAY_ help to move that rewrite to httpd.conf.
In many cases rewrite rules in httpd.conf get 
processed at an earlier stage than those in 
.htaccess.  This is becase Apace can't read 
the .htacces file until after it resolves the 
URL into a filename, so it knows which directories
to look for .htaccess files in.  That occurs 
quite late in the process, during the fixup hook.

   Other than that, I can only suggest that there 
are several http headers designed for the purpose 
of controlling caching so that just the right things 
are cached for just the right amount of time, and 
only under the right conditions.  Using that carefully 
designed and well established system may yield better 
results than the "big hammer" approach of sticking 
bogus junk into the URL, then trying to remove it 
later for certain kinds of caching.  You've added
that to try to prevent caching, yet clearly the 
content SHOULD be cached in some cases, as is 
clear because you are actually wanting to cache 
it.  Rather than inventing your own caching 
system, look into setting the appropriate headers
so that it's cached when appropriate and for the 
appropriate amount of time.
--
Ray B. Morris
supp...@bettercgi.com

Strongbox - The next generation in site security:
http://www.bettercgi.com/strongbox/

Throttlebox - Intelligent Bandwidth Control
http://www.bettercgi.com/throttlebox/

Strongbox / Throttlebox affiliate program:
http://www.bettercgi.com/affiliates/user/register.php


On 03/19/2009 02:36:23 PM, Anthony J. Biacco wrote:
> I posted this on the users list, but didn't get any help, so I'm
> hoping
> the dev people here can either help or at least explain if what I'm
> seeing below is how it's meant to work..
> 
> I have a uri with cachebusting in it that looks like this:
> /path?killCache=x¶meter1=y%parameter2=z
> where x is a unix timestamp used to make sure the url isn't cached by
> the browser.
> 
> Now though I want to use apache disk caching on this url. Obviously
> with
> the killCache parameters always changing though, this is futile. And 
> I
> can't ignore the query string with CacheIgnoreQueryString because
> parameter1 and parameter2 are important to the output to the end-
> user,
> so the cache would be inconsistent if I had caching ignore the query
> string.
> 
> So I decided to rewrite the url to remove the killCache parameter, 
> and
> while this rule itself works fine (I'm rewriting to a path not a full
> url), it seems the cache check is done before the rewrite.
> 
> My rule is:
> 
> RewriteCond %{QUERY_STRING}
> ^killCache=(.+)\¶meter1=(.+)\¶meter2=(.+)
> RewriteRule ^/path /path?parameter1=%2¶meter2=%3 [L]
> 
> And in the log I see:
> 
>  [Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(131): Adding
> CACHE_SAVE
> filter for /path
> [Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(138): Adding
> CACHE_REMOVE_URL filter for /path
> [Wed Mar 18 12:02:47 2009] [debug] mod_headers.c(740): headers:
> ap_headers_output_filter()
> mod_cache.c(639): cache: Caching url:
> /path?killCache=x¶meter1=y¶meter2=z 
> [Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(645): cache: Removing
> CACHE_REMOVE_URL filter. 
> [Wed Mar 18 12:02:47 2009] [debug] mod_disk_cache.c(962): disk_cache:
> Stored headers for URL
> http://myhost/path?killCache=x¶meter1=y¶meter2=z
> [Wed Mar 18 12:02:47 2009] [debug] mod_disk_cache.c(1051): 
> disk_cache:
> Body for URL http://myhost/path?killCache=x¶meter1=y¶meter2=z
> cached.
> 
> And I get a different cache file stored for every value of the
> parameter
> killCache.
> 
> Anybody know a way to get the rewriterule processed before the cache
> mechanism? I can rewrite to a full url and the new request will then
> pull from cache, but that induces an extra request and an extra log
> entry, which I'd like to avoid if at all possible.
> 
> Thanx,
> 
> -Tony
> ---
> Manager, IT Operations
> Format Dynamics, Inc.
> 303-573-1800x27
> abia...@formatdynamics.com
> http://www.formatdynamics.com
> 
> 




rewrite before caching?

2009-03-19 Thread Anthony J. Biacco
I posted this on the users list, but didn't get any help, so I'm hoping
the dev people here can either help or at least explain if what I'm
seeing below is how it's meant to work..

I have a uri with cachebusting in it that looks like this:
/path?killCache=x¶meter1=y%parameter2=z
where x is a unix timestamp used to make sure the url isn't cached by
the browser.

Now though I want to use apache disk caching on this url. Obviously with
the killCache parameters always changing though, this is futile. And I
can't ignore the query string with CacheIgnoreQueryString because
parameter1 and parameter2 are important to the output to the end-user,
so the cache would be inconsistent if I had caching ignore the query
string.

So I decided to rewrite the url to remove the killCache parameter, and
while this rule itself works fine (I'm rewriting to a path not a full
url), it seems the cache check is done before the rewrite.

My rule is:

RewriteCond %{QUERY_STRING}
^killCache=(.+)\¶meter1=(.+)\¶meter2=(.+)
RewriteRule ^/path /path?parameter1=%2¶meter2=%3 [L]

And in the log I see:

 [Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(131): Adding CACHE_SAVE
filter for /path
[Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(138): Adding
CACHE_REMOVE_URL filter for /path
[Wed Mar 18 12:02:47 2009] [debug] mod_headers.c(740): headers:
ap_headers_output_filter()
mod_cache.c(639): cache: Caching url:
/path?killCache=x¶meter1=y¶meter2=z 
[Wed Mar 18 12:02:47 2009] [debug] mod_cache.c(645): cache: Removing
CACHE_REMOVE_URL filter. 
[Wed Mar 18 12:02:47 2009] [debug] mod_disk_cache.c(962): disk_cache:
Stored headers for URL
http://myhost/path?killCache=x¶meter1=y¶meter2=z
[Wed Mar 18 12:02:47 2009] [debug] mod_disk_cache.c(1051): disk_cache:
Body for URL http://myhost/path?killCache=x¶meter1=y¶meter2=z
cached.

And I get a different cache file stored for every value of the parameter
killCache.

Anybody know a way to get the rewriterule processed before the cache
mechanism? I can rewrite to a full url and the new request will then
pull from cache, but that induces an extra request and an extra log
entry, which I'd like to avoid if at all possible.

Thanx,

-Tony
---
Manager, IT Operations
Format Dynamics, Inc.
303-573-1800x27
abia...@formatdynamics.com
http://www.formatdynamics.com



MaxRequestsPerChild for MPM worker threads?

2009-03-19 Thread Andrej van der Zee
Hi,

Is there a way to let a MPM worker thread exit after serving X requests? I
need to do some tests that requires checking if my custom hook
ap_hook_thread_exit() is called properly. I found a directive to have one
thread per child that gets me in the right direction (ThreadsPerChild 1).
Now I need one to set the maximum number of requests served by a thread to
get a fast thread_exit(). I tried MaxRequestsPerChild but it does not seem
to do what I want. BTW, I start apache like "/usr/local/apache2/bin/httpd -X
&".

What option(s) could I use to force worker threads to exit after serving few
requests?

Thank you,
Andrej


Re: child_init for threads?

2009-03-19 Thread Andrej van der Zee
Hi,


>
> apr_os_thread_t os_thd = apr_os_thread_current ();
> apr_thread_t *apr_thd;
> apr_status_t apr_os_thread_put(&apr_thd, &os_thd, r->pool);
>

Okay, this clearly doesn't work. I misunderstood the documentation,
but the sources don't lie. Anyway, how can I get the apr_thread_t for
the current thread in a module for MPM worker?

Cheers,
Andrej