Re: mod_disk_cache problem
On Tue, Mar 25, 2003 at 03:20:49PM +0200, Ori Tend wrote: I did set mod_expires to set an expiry date of access plus 1 week - and when I GET the urls from the site I see the correct Expires: value in the header- Yet mod_disk_cache won't cache any dynamic content (perl scripts, tomcat jsp's, etc). It does cache all the static content that apache fetches from the disk, though. Any idea why would that happen? Not really. Sorry. My only guess is that mod_expires adds the headers after the request has been handled by mod_cache. I suspect this behaviour would not be specific to mod_disk_cache but to mod_cache. Have you turned on debugging in your server configuration (LogLevel debug)? The source indicates (see excerpt below) that you should see log entries stating why the request is not being cached. [...] } else if (r-args exps == NULL) { /* if query string present but no expiration time, don't cache it * (RFC 2616/13.9) */ reason = Query string present but no expires header; } [...] if (reason) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r-server, cache: %s not cached. Reason: %s, url, reason); cu - Harry
RE: mod_disk_cache problem
Hi Harry, I did set mod_expires to set an expiry date of access plus 1 week - and when I GET the urls from the site I see the correct Expires: value in the header- Yet mod_disk_cache won't cache any dynamic content (perl scripts, tomcat jsp's, etc). It does cache all the static content that apache fetches from the disk, though. Any idea why would that happen? Thanks, Ori. -Original Message- From: harald deppeler [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2003 6:32 PM To: Ori Tend Cc: [EMAIL PROTECTED] Subject: Re: mod_disk_cache problem Hi Ori On Wed, Mar 19, 2003 at 04:14:45PM +0200, Ori Tend wrote: Hi again Harry, Just wanted to let you know you've helped me :-) It really was the case- I chown-ed the cache directory to user nobody, and apached started to fill it with some files... I assumed that it should be the same owner as the owner of the other apache log files.. I assumed wrong :-) Glad this helped. I remember bumping into this as well ... I have another question, though- it looks like apache doesn't cache the dynamic info that tomcat generates (tomcat is connected via mod_jk). Any idea why? I also tried to enable mod_proxy, but it didn't help- tomcat still receives the same requests again and again, even though apache is supposed to cache it... The way I understand it: mod_cache caches according to the HTTP RFC, which means that the back-end ought to provide appropriate headers that help the cache determine how long it should cache the data. If the backend does not provide any such headers (expire, last-modified), the cache doesn't cache, especially if the URL contains a query string. At work I recently ran into a similar problem. (Pseudo-) dynamic back-end content with no such cache-friendly headers *had* to be cached (or our site would performance crash) and we modified a 2.0.44 vanilla Apache to serve our needs. Since most changes are a rather quick hack and since they violate the RFC, I did not dare to propose them to the list but feel free to use them (they should be attached to this mail). You would patch like #!/bin/sh -ex DIRECTORY=httpd-2.0.44 files_to_patch=mod_cache.c mod_disk_cache.c path_to_files=${DIRECTORY}/modules/experimental for file in $files_to_patch do patch ${path_to_files}/$file ${file}.diff done exit 0 before doing the make to compile. The patch also enables that URLs ending with a / are cached. Cheers - Harry Thanks, Ori. -Original Message- From: Ori Tend [mailto:[EMAIL PROTECTED] Sent: Sunday, March 16, 2003 8:03 PM To: 'harald deppeler' Subject: RE: mod_disk_cache problem Hi Harry, First off, thanks for your reply :-) /usr/local/apache2/proxy owned by root- and I run apache always as root (also, all of apache's other directories are owned by root, so I assume this is ok for apache). I tried to play with the CacheDefaultExpire, hoping that is the reason why apache didn't write anything to the CacheRoot directory, but it didn't help- apache doesn't write anything to that directory... I kind of suspect it has to do with a compilation option I didn't set or so... But I really don't know which... Ori. -Original Message- From: harald deppeler [mailto:[EMAIL PROTECTED] Sent: Sunday, March 16, 2003 7:10 PM To: Ori Tend Subject: Re: mod_disk_cache problem On Sun, Mar 16, 2003 at 04:03:35PM +0200, Ori Tend wrote: I'm using apache standard cache configuration (loading mod_disk_cache). Yet for some reason, apache doesn't write anything to the CacheRoot dir. Just to make sure I didn't do anything wrong, I reinstalled apache again- this time on Win32, and using the exact same cache configuration apache cached all the urls, as it should have. Just to make sure it doesn't have to do with mod_jk2 and tomcat connectivity, I tried to see if apache caches static content (html files which are not served by tomcat) - and apache didn't cache those as well. any help would be greatly appreciated... my httpd.conf (all is default, commented in the following): LoadModule cache_module modules/mod_cache.so LoadModule disk_cache_module modules/mod_disk_cache.so CacheRoot /usr/local/apache2/proxy CacheSize 5 CacheGcInterval 4 CacheMaxExpire 24 CacheLastModifiedFactor 0.1 CacheDefaultExpire 1 CacheEnable disk / Is /usr/local/apache2/proxy writable by the httpd UID? Does your backend service generate HTTP headers that set the caching expiry time? If not, your default expiry time would be 1 second. Is that really what you want? If any of this helps, please post the solution to the list. Cheers - Harry
Re: mod_disk_cache problem
Hi Ori On Wed, Mar 19, 2003 at 04:14:45PM +0200, Ori Tend wrote: Hi again Harry, Just wanted to let you know you've helped me :-) It really was the case- I chown-ed the cache directory to user nobody, and apached started to fill it with some files... I assumed that it should be the same owner as the owner of the other apache log files.. I assumed wrong :-) Glad this helped. I remember bumping into this as well ... I have another question, though- it looks like apache doesn't cache the dynamic info that tomcat generates (tomcat is connected via mod_jk). Any idea why? I also tried to enable mod_proxy, but it didn't help- tomcat still receives the same requests again and again, even though apache is supposed to cache it... The way I understand it: mod_cache caches according to the HTTP RFC, which means that the back-end ought to provide appropriate headers that help the cache determine how long it should cache the data. If the backend does not provide any such headers (expire, last-modified), the cache doesn't cache, especially if the URL contains a query string. At work I recently ran into a similar problem. (Pseudo-) dynamic back-end content with no such cache-friendly headers *had* to be cached (or our site would performance crash) and we modified a 2.0.44 vanilla Apache to serve our needs. Since most changes are a rather quick hack and since they violate the RFC, I did not dare to propose them to the list but feel free to use them (they should be attached to this mail). You would patch like #!/bin/sh -ex DIRECTORY=httpd-2.0.44 files_to_patch=mod_cache.c mod_disk_cache.c path_to_files=${DIRECTORY}/modules/experimental for file in $files_to_patch do patch ${path_to_files}/$file ${file}.diff done exit 0 before doing the make to compile. The patch also enables that URLs ending with a / are cached. Cheers - Harry Thanks, Ori. -Original Message- From: Ori Tend [mailto:[EMAIL PROTECTED] Sent: Sunday, March 16, 2003 8:03 PM To: 'harald deppeler' Subject: RE: mod_disk_cache problem Hi Harry, First off, thanks for your reply :-) /usr/local/apache2/proxy owned by root- and I run apache always as root (also, all of apache's other directories are owned by root, so I assume this is ok for apache). I tried to play with the CacheDefaultExpire, hoping that is the reason why apache didn't write anything to the CacheRoot directory, but it didn't help- apache doesn't write anything to that directory... I kind of suspect it has to do with a compilation option I didn't set or so... But I really don't know which... Ori. -Original Message- From: harald deppeler [mailto:[EMAIL PROTECTED] Sent: Sunday, March 16, 2003 7:10 PM To: Ori Tend Subject: Re: mod_disk_cache problem On Sun, Mar 16, 2003 at 04:03:35PM +0200, Ori Tend wrote: I'm using apache standard cache configuration (loading mod_disk_cache). Yet for some reason, apache doesn't write anything to the CacheRoot dir. Just to make sure I didn't do anything wrong, I reinstalled apache again- this time on Win32, and using the exact same cache configuration apache cached all the urls, as it should have. Just to make sure it doesn't have to do with mod_jk2 and tomcat connectivity, I tried to see if apache caches static content (html files which are not served by tomcat) - and apache didn't cache those as well. any help would be greatly appreciated... my httpd.conf (all is default, commented in the following): LoadModule cache_module modules/mod_cache.so LoadModule disk_cache_module modules/mod_disk_cache.so CacheRoot /usr/local/apache2/proxy CacheSize 5 CacheGcInterval 4 CacheMaxExpire 24 CacheLastModifiedFactor 0.1 CacheDefaultExpire 1 CacheEnable disk / Is /usr/local/apache2/proxy writable by the httpd UID? Does your backend service generate HTTP headers that set the caching expiry time? If not, your default expiry time would be 1 second. Is that really what you want? If any of this helps, please post the solution to the list. Cheers - Harry 98a99 char *query = uri.query; /* HD: added */ 115c116,125 if (!(types = ap_cache_get_cachetype(r, conf, path))) { --- /* HD: changed 3rd arg 'path' to 'url' * this will check the the cache type for the URL with query string * (instead of just checking the path part) * * Also added a logger statement. */ if (!(types = ap_cache_get_cachetype(r, conf, url))) { ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r-server, cache: URL with path %s and query string %s (url %s) is not handled by cache., path, query, url); 128c138,139 if (url[urllen-1] == '/') { --- /* HD: commented the following block in order to also cache URL ending in '/' */ /* if (url[urllen-1] == '/') { 130c141 } --- }*/ 532c543,547 else if (r-args exps == NULL
Re: mod_disk_cache problem
Ori Tend wrote: I'm using apache standard cache configuration (loading mod_disk_cache). Yet for some reason, apache doesn't write anything to the CacheRoot dir. Try enabling debug logging: LogLevel debug The caching modules print a lot of information. Maybe something will show up in the error_log that can help to solve your problem. -- ir. Kris Verbeeck Development Engineer Ubizen - Ubicenter - Philipssite 5 - 3001 Leuven - Belgium T: +32 16 28 70 64 F: +32 16 28 70 77 Ubizen - We Secure e-business - www.ubizen.com
Re: mod_disk_cache problem
Ori Tend wrote: I'm using apache standard cache configuration (loading mod_disk_cache). Yet for some reason, apache doesn't write anything to the CacheRoot dir. Are you sure Apache is allowed to write to your cache directory? Check the permissions and ownership. Does the cache directory exist? (Been bitten by this before). Regards, Graham -- - [EMAIL PROTECTED] There's a moon over Bourbon Street tonight...