Bug 21492 - Bad file size in disk cache for large css files
Summary: Bad file size in disk cache for large css files
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_cache (show other bugs)
Version: 2.0.51
Hardware: Other AIX
: P3 major (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2003-07-11 09:01 UTC by sebastien gautrias
Modified: 2004-11-16 19:05 UTC (History)
1 user (show)



Attachments
.header and .data files (14.24 KB, application/octet-stream)
2003-07-11 09:02 UTC, sebastien gautrias
Details
Proposed Patch (2.86 KB, patch)
2004-08-24 08:54 UTC, Rüdiger Plüm
Details | Diff
Patch for 2.0.51 (1.43 KB, patch)
2004-09-23 11:18 UTC, Rüdiger Plüm
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description sebastien gautrias 2003-07-11 09:01:31 UTC
Overview Description :

Some css size are not good into httpd cache disk.

Here my cache configuration :

<IfModule mod_cache.c>
	<IfModule mod_disk_cache.c>
		CacheRoot /cacheproxy/CR844-Production-SSL
		CacheSize 100000
		CacheEnable disk /
		CacheDirLevels 1
		CacheDirLength 2
		CacheMaxExpire 86400
		CacheDefaultExpire 7200
		CacheForceCompletion 100
	</IfModule>
</IfModule>

And the results of my observations (we have 5 urls for the same file, because we
use dispatching into url) :

Normal size : 43648 bytes (43648 Jul 10 18:39 feuille.css)

Into the Httpd cache disk (bytes) : The header Content-Length is always : 43648
Into the disk (size in bytes) : (we have only write the affinity)
- /g1/ssl/css/feuille.css --> 	25716 ===> KO
- /g1_k/ssl/css/feuille.css -->	43648 ===> OK
- /g1_l/ssl/css/feuille.css -->	43648 ===> OK
- /g1_m/ssl/css/feuille.css -->	28476 ===> KO
- /g1_n/ssl/css/feuille.css -->	43648 ===> OK


Steps to Reproduce: This problem is not reproducible.

Actual Results: The navigator show some page with css file not complete ==> Bad
posting

Expected Results: Good file size into disk cache

Build Date & Platform: Apache 2.0.46 build on AIX 5.1 FP3, H70 server 64 bits,
compiled with gcc 3.2.3, Apache 32 bits

Additional Builds and Platforms: Apache 2.0.45 on AIX 5.2, p610 server 64 bits,
compiled with XLC  6.0.0.5, Apache 64 bits
Comment 1 sebastien gautrias 2003-07-11 09:02:35 UTC
Created attachment 7239 [details]
.header and .data files
Comment 2 Rüdiger Plüm 2004-08-24 08:53:48 UTC
I guess my problem is the same. I use mod_disk_cache to cache static files
delivered by Tomcat via
mod_jk. Unfortunately you did not write if you are caching local files or remote
files (delivered
by mod_jk, mod_proxy or something similar).

I noticed that when you abort the download of a file which should be cached and
whos origin is
on a remote server, the partly downloaded file gets cached.
The second request for this file only delivers the partly cached file and thus
leads to the problems
described by you. In my case the problem showed up by incomplete jpg pictures.

The reason for this behaviour can be found in mod_disk_cache. mod_disk_cache
does not notice
that a request has been aborted. I wrote a small patch (against 2.0.50) that
drops the partly cached file
if the connection has been aborted. 
Unfortunately the CacheForceCompletion of mod_cache is not implemented right now
such that nearly
completely downloaded files get lost for the cache. But this is better than
delivering only
parts of the files in the following requests.
Comment 3 Rüdiger Plüm 2004-08-24 08:54:48 UTC
Created attachment 12516 [details]
Proposed Patch
Comment 4 Paul Querna 2004-09-19 20:03:51 UTC
Can you please test this in 2.0.51?

Lots of fixes for mod_disk_cache were made.
Comment 5 Rüdiger Plüm 2004-09-23 11:18:00 UTC
I checked this with 2.0.51 and it is only partially fixed. It should work with
local files, but it does not work if
the length of the content to be cached is unknown and the file is large as it is
the case if you cache large dynamic
content originally created by Tomcat. And this is what I am doing. I try to
lower the load on the Tomcats by caching
large files generated by Tomcat that are valid for some time via mod_cache on
the webserver.


The problem is that in this case we get to line 663 of mod_disk_cache.c as the
condition in line 661 is true in
any case (content written completely to file or only partially because the
connection has been aborted).
So this operation is handled as successful caching of the request in any case
even if the content was only
saved partially.


Nevertheless the changes to mod_disk_cache provide an better environment now for
the needed changes so I provide
an updated version of my patch for 2.0.51.
Comment 6 Rüdiger Plüm 2004-09-23 11:18:36 UTC
Created attachment 12847 [details]
Patch for 2.0.51
Comment 7 Justin Erenkrantz 2004-09-28 17:41:49 UTC
A variant of the 'patch for 2.0.51' has been committed to HEAD as
modules/experimental/mod_disk_cache.c rev 1.64.

Thanks!
Comment 8 Graham Leggett 2004-10-13 16:43:15 UTC
Backported to v2.0.53.