Apache 2.4 mod_cache + mod_cache_disk + modjk:304未修改,但内容长度已修改

ux6nzvsh  于 12个月前  发布在  Apache
关注(0)|答案(2)|浏览(130)

我对mod_cache很着迷!
我当前的设置:
Ubuntu上的Apache 2.4:

  • mpm_worker
  • mod_jk
  • mod_cache
  • mod_cache_disk
  • mod_expires
  • 模式放气
    HTTP和HTTPS请求由modjk平衡到5个Tomcat AppServer。我想缓存由Tomcat服务器提供的媒体资产,但mod_cache有问题。
    我当前的缓存配置:
CacheRoot /srv/volatile/cache
    CacheDirLevels 3
    CacheDirLength 2
    CacheEnable disk /medias

    # Currently active:
    CacheQuickHandler off
    CacheLock on
    CacheLockPath /tmp/mod_cache-lock
    CacheLockMaxAge 5
    CacheIgnoreHeaders Set-Cookie

    # This is another configuration i tried:
    #CacheIgnoreNoLastMod On
    #CacheIgnoreCacheControl On
    #CacheIgnoreQueryString On
    #CacheIgnoreHeaders Set-Cookie

我检查了很多教程和指南,但没有成功。
第一个请求被Apache很好地服务,下面的请求失败,出现奇怪的错误:

Recalled cached URL info header https://...
Recalled headers for URL https://...
Adding CACHE_SAVE filter for /medias...
Adding CACHE_REMOVE_URL filter for /medias...
cache: /media... responded with an uncacheable 304, retrying the request. Reason: contradiction: 304 Not Modified, but Content-Length modified
cache: Removing url https://
Deleting /srv/volatile/cache/.../.header from cache.
Deleting /srv/volatile/cache/.../.data from cache.
Deleting directory /srv/volatile/cache/.../7n from cache.
URL https://... failed the size check (0 < 1)

我认为这可能是一个负载平衡问题,因为walk抛出了多个节点或类似的东西,但行为不是确定性的。使用apache-bench和jmeter进行的测试表明,60-70%的请求失败,所以并不是每个X请求都失败了。
如果设置了CacheIgnoreCacheControl On选项,则抛出jmeter & apache-bench的请求不会失败,但访问抛出Browser失败。
有人知道吗?
谢谢陶朗

iq0todco

iq0todco1#

我认为,这是由mod_cache bug 56881覆盖的,它在Apache 2.4.11中得到了修复。

uajslkp6

uajslkp62#

原因就在这条线的后面:

responded with an uncacheable 304, retrying the request. Reason: contradiction: 304 Not Modified, but Content-Length modified

您的后端正确地回复了一个304响应,但错误地回复了一个Content-Length标头,可能是零值

相关问题