httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ion Alexandru Morega <al...@iem.pub.ro>
Subject Re: [users@httpd] mod_disk_cache with mod_deflate not sending If-Modified-Since to tomcat webapp
Date Wed, 23 May 2007 21:36:47 GMT
On 13 May 2007, at 16:05, Ion Alexandru Morega wrote:
> Hi.
>
> I'm having trouble using mod_cache/mod_disk_cache and mod_deflate  
> at the same time.
>
> My setup is like this: one Tomcat 5.5 webapp, Apache 2.2.3 + mod_jk  
> 1.2.18. The intent is to cache pages generated by the webapp; as  
> long as the page content is not changed, pages should be served  
> from Apache's cache (communication between apache and the webapp is  
> done through Last-Modified and If-Modified-Since HTTP headers). It  
> works well if I don't use mod_deflate; as soon as I enable  
> mod_deflate compression, Apache seems to ignore its cache.
>
> here is a configuration snippet:
> ---
> AddOutputFilterByType DEFLATE text/html text/plain text/xml  
> application/x-javascript text/css
> CacheRoot /var/test_app/cache
> CacheDirLevels 1
> CacheDirLength 1
> CacheEnable disk /cache_test
> CacheIgnoreHeaders Set-Cookie Cookie Cache-Control Pragma
> CacheIgnoreCacheControl On
> CacheMaxExpire 0
> ---
>
> CacheDirLevels and CacheDirLength are set to 1 to make it easier to  
> look into the cache directory. I set CacheMaxExpire to zero because  
> I don't want any "blind" caching of documents; each and every  
> request must ask the Tomcat webapp whether the cached data is  
> fresh. I'm deliberately ignoring any user agent's cache control  
> headers because I trust my own caching mechanism to provide fresh  
> data (I tried working with many permutations of CacheIngoreHeaders  
> and CacheIgnoreCacheControl, including commenting out both, none  
> worked properly with mod_deflate).
>
> Comparing the behaviour with / without mod_deflate, I've seen some  
> interesting things.
>
> Firstly, without mod_deflate, the first request for the page causes  
> the Tomcat webapp to generate the page, which is then stored in the  
> cache. Any subsequent request will reach Tomcat with a "If-Modified- 
> Since" header, containing the date that Tomcat previously sent as  
> "Last-Modified" (and if Tomcat replies with a 304 Not Modified  
> status, the page is served from cache). I haven't been able to get  
> any user-agent to trick Apache into sending a request without "If- 
> Modified-Since". Looking into the on-disk cache, I see two files  
> generated for this page - one [hashcode].header and one  
> [hashcode].data file. This all is, as I understand, correct behaviour.
>
> Now, with mod_deflate enabled, if the browser's request contains no  
> "If-Modified-Since" header, Apache will not send "If-Modified- 
> Since" either. The page is therefore generated all over again, even  
> if it was already in the cache. Looking into the cache folder, i  
> now see an extra [hashcode].header.vary directory, that contains  
> different cached responses for different user-agents.  
> Interestingly, if the user-agent request contains an "If-Modified- 
> Since" header, it's passed on to Tomcat, and the page is not  
> generated again (because it's cached by the browser).
>
> I have tried this configuration with apache 2.2.4 and mod_jk  
> 1.2.22, and the problem is the same.
>
> I'm now experimenting with mod_mem_cache, which seems to work well,  
> but it sometimes forgets to send "If-Modified-Since" headers too.  
> Still, I'd rather use mod_disk_cache if I could.
>
> I hope this information is detailed enough; if not, I'll gladly  
> explain more.
>
> Thanks,
> -- Alex

Hi. Just wanted to bring up this issue again. I've ended up writing a  
custom cache in Java, but I'd much rather use Apache's mod_disk_cache.

Thanks,
-- Alex


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message