|Summary:||mod_disk_cache breakes Content-Type for .css files|
|Product:||Apache httpd-2||Reporter:||Igor Fedulov <igor>|
|Component:||mod_cache||Assignee:||Apache HTTPD Bugs Mailing List <bugs>|
|Severity:||major||CC:||mr, p.beckett, webform001|
|Bug Depends on:||27791|
proposed solution patch to mod_disk_cache.c
Patch against 2.0.51
Description Igor Fedulov 2004-07-22 23:11:21 UTC
After .css file was cached with mod_disk_cache it is served with wrong content type. Instead of "text/css" it's served with "text/plain; charset=UTF-8" Configuration: ... <IfModule mod_cache.c> <IfModule mod_disk_cache.c> CacheRoot "/tmp/abc_static_cache" CacheEnable disk /abc/images CacheEnable disk /abc/htmlarea CacheEnable disk /abc/scripts CacheEnable disk /abc/style </IfModule> </IfModule> ... "/abc" context is referse proxy forward to backend server using following two directives: ... ProxyPass /abc http://10.10.10.10:8080/abc ProxyPassReverse /abc http://10.10.10.10:8080/abc ... Here is the headers printout for very first request (right after clean apache restart with purging of the caches folder): [igor@hyperion tmp]$ wget -s https://18.104.22.168/abc/style/common.css ; head common.css; rm -rf common.css --18:04:39-- https://22.214.171.124/abc/style/common.css => `common.css' Connecting to [126.96.36.199]:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10,368 [text/css] 100%[==============================================================================================>] 10,368 105.47K/s ETA 00:00 18:04:40 (105.47 KB/s) - `common.css' saved [10368/10368] HTTP/1.1 200 OK Date: Thu, 22 Jul 2004 23:04:26 GMT Server: Apache/2.0.50 (Fedora) Content-Length: 10368 Last-Modified: Thu, 22 Jul 2004 16:50:00 GMT Accept-Ranges: bytes Content-Type: text/css Vary: Accept-Encoding,User-Agent Keep-Alive: timeout=30, max=100 Connection: Keep-Alive Each subsequent request for the same URL returns following headers: [igor@hyperion tmp]$ wget -s https://188.8.131.52/abc/style/common.css ; head common.css; rm -rf common.css --18:04:52-- https://184.108.40.206/abc/style/common.css => `common.css' Connecting to [220.127.116.11]:443... connected. HTTP request sent, awaiting response... 200 OK Length: 10,368 [text/plain] 100%[==============================================================================================>] 10,368 117.73K/s ETA 00:00 18:04:53 (117.73 KB/s) - `common.css' saved [10368/10368] HTTP/1.1 200 OK Date: Thu, 22 Jul 2004 23:04:39 GMT Server: Apache/2.0.50 (Fedora) Accept-Ranges: bytes Content-Length: 10368 Last-Modified: Thu, 22 Jul 2004 16:50:00 GMT Content-Type: text/plain; charset=UTF-8 Age: 17 Keep-Alive: timeout=30, max=100 Connection: Keep-Alive [igor@hyperion tmp]$ I can provide more information if needed, feel free to email me for more questions.
Comment 1 Paul Querna 2004-07-23 01:25:04 UTC
is utf8 your default charset type? What is 'AddDefaultCharset' set to in your httpd.conf?
Comment 2 Igor Fedulov 2004-07-23 01:42:49 UTC
It's set to UTF-8, i.e. from httpd.conf: AddDefaultCharset UTF-8
Comment 3 Rüdiger Plüm 2004-08-04 15:04:21 UTC
Does this only happen with css files or also with other files? What is your setting for DefaultType ? Is it unset or text/plain? I had a similar problem with mod_jk and mod_cache / mod_disk_cache. I would guess that they are related. See also http://nagoya.apache.org/bugzilla/show_bug.cgi?id=30398.
Comment 4 Igor Fedulov 2004-08-04 15:36:09 UTC
Here are my answers: 1. DefaultType is set to "text/plain" 2. Images from cache also come out with "Content-Type: text/plain; charset=UTF-8" Looks like what you are describing in your issue is exactly the same thing, I wonder if I can try your patch to see if it will fix the problem.
Comment 5 Rüdiger Plüm 2004-08-04 20:48:50 UTC
No, you cannot use my patch as I patched mod_jk to solve my problem. You need a patch for mod_disk_cache. But as I mentioned in 30398, I was not quite sure if this problem is a bug in mod_jk or mod_cache / mod_disk_cache (BTW: mod_mem_cache does not have this problem). After I read this report here I am quite sure that it is a bug in mod_disk_cache and that it should be fixed there. mod_disk_cache.c already contains the needed code in write_headers, but it is executed too late. So I just moved this piece of code and created an appropriate patch for this which I will attach. I removed my patch from my mod_jk and added my patch to mod_disk_cache and my problem from 30398 remains silent. I hope that this patch will also solve your problem. A short feedback on your experience with the patch would be much appreciated. BTW: If you have any problems with mod_cache storing Cookies unintentional, or with other weird HTTP header caching behaviour you may find the following links useful: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=30399 http://nagoya.apache.org/bugzilla/show_bug.cgi?id=30419
Comment 6 Rüdiger Plüm 2004-08-04 20:49:45 UTC
Created attachment 12339 [details] proposed solution patch to mod_disk_cache.c
Comment 7 Igor Fedulov 2004-08-04 21:43:01 UTC
I've tested this patch and it works perfectly. After either image or .css file is cached headers contain proper Content-Type thus allowing for proper display in strict HTML validating browsers! Thanks! Here is the output from the original wget commands: 1. First request for a resource: 16:36:57 (328.88 KB/s) - `common.css' saved [10440/10440] HTTP/1.1 200 OK Date: Wed, 04 Aug 2004 21:36:56 GMT Server: Apache/2.0.50 (Fedora) Content-Length: 10440 Last-Modified: Fri, 23 Jul 2004 12:56:12 GMT Accept-Ranges: bytes Content-Type: text/css Vary: Accept-Encoding,User-Agent Keep-Alive: timeout=30, max=100 Connection: Keep-Alive 2. Next request for the same resource: 16:36:59 (463.42 KB/s) - `common.css' saved [10440/10440] HTTP/1.1 200 OK Date: Wed, 04 Aug 2004 21:36:59 GMT Server: Apache/2.0.50 (Fedora) Accept-Ranges: bytes Content-Length: 10440 Last-Modified: Fri, 23 Jul 2004 12:56:12 GMT Content-Type: text/css Age: 4 Keep-Alive: timeout=30, max=100 Connection: Keep-Alive
Comment 8 Rüdiger Plüm 2004-08-18 11:13:13 UTC
*** Bug 29016 has been marked as a duplicate of this bug. ***
Comment 9 Rüdiger Plüm 2004-09-28 12:26:16 UTC
Created attachment 12879 [details] Patch against 2.0.51
Comment 10 Justin Erenkrantz 2004-09-28 17:42:49 UTC
A variant of the 'patch against 2.0.51' has been committed to HEAD as modules/experimental/mod_disk_cache.c rev 1.63. Thanks!
Comment 11 Graham Leggett 2004-10-13 16:38:41 UTC
Backported to v2.0.53.
Comment 12 Paul Beckett 2012-06-19 14:28:01 UTC
I think I'm seeing this same issue in Apache 2.4.2 on RHEL6.2. I am using Apache ModProxy to proxy to a tomcat, when this is unavailable, content should continue to be served using mod_cache_disk. I'm seeing the Content-Type and Charset change when served from the disk_cache - this doesn't seem to happen immediately, and I presume it's related to the content becoming stale. Header output below. Please let me know if there is any additional information I can provide that would help. Thanks, Paul ----------------------- When tomcat available ----------------------- Date Tue, 19 Jun 2012 14:18:40 GMT Age 6 Connection Keep-Alive Content-Length 339 Last-Modified Mon, 18 Jun 2012 15:50:24 GMT Server Web Server ETag W/"339-1340034624000" Content-Type text/css;charset=utf-8 Accept-Ranges bytes Keep-Alive timeout=3, max=99 ----------------------- When tomcat unavailable - from disk_cache ----------------------- Date Tue, 19 Jun 2012 08:48:53 GMT Connection close Content-Length 339 Last-Modified Mon, 18 Jun 2012 15:50:24 GMT Server Apache-Coyote/1.1 ETag W/"339-1340034624000" Warning 111 Revalidation failed Content-Type text/html; charset=iso-8859-1 Accept-Ranges bytes