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://1.2.3.4/abc/style/common.css ; head common.css; rm -rf common.css --18:04:39-- https://1.2.3.4/abc/style/common.css => `common.css' Connecting to [1.2.3.4]: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://1.2.3.4/abc/style/common.css ; head common.css; rm -rf common.css --18:04:52-- https://1.2.3.4/abc/style/common.css => `common.css' Connecting to [1.2.3.4]: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.
is utf8 your default charset type? What is 'AddDefaultCharset' set to in your httpd.conf?
It's set to UTF-8, i.e. from httpd.conf: AddDefaultCharset UTF-8
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.
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.
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
Created attachment 12339 [details] proposed solution patch to mod_disk_cache.c
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
*** Bug 29016 has been marked as a duplicate of this bug. ***
Created attachment 12879 [details] Patch against 2.0.51
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!
Backported to v2.0.53.
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