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

ux6nzvsh  于 2023-10-23  发布在  Apache
关注(0)|答案(2)|浏览(160)

我对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有问题。
    我当前的缓存配置:
  1. CacheRoot /srv/volatile/cache
  2. CacheDirLevels 3
  3. CacheDirLength 2
  4. CacheEnable disk /medias
  5. # Currently active:
  6. CacheQuickHandler off
  7. CacheLock on
  8. CacheLockPath /tmp/mod_cache-lock
  9. CacheLockMaxAge 5
  10. CacheIgnoreHeaders Set-Cookie
  11. # This is another configuration i tried:
  12. #CacheIgnoreNoLastMod On
  13. #CacheIgnoreCacheControl On
  14. #CacheIgnoreQueryString On
  15. #CacheIgnoreHeaders Set-Cookie

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

  1. Recalled cached URL info header https://...
  2. Recalled headers for URL https://...
  3. Adding CACHE_SAVE filter for /medias...
  4. Adding CACHE_REMOVE_URL filter for /medias...
  5. cache: /media... responded with an uncacheable 304, retrying the request. Reason: contradiction: 304 Not Modified, but Content-Length modified
  6. cache: Removing url https://
  7. Deleting /srv/volatile/cache/.../.header from cache.
  8. Deleting /srv/volatile/cache/.../.data from cache.
  9. Deleting directory /srv/volatile/cache/.../7n from cache.
  10. 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#

原因就在这条线的后面:

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

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

相关问题