【问题标题】:Apache 2.4 mod_cache + mod_cache_disk + modjk: 304 Not Modified, but Content-Length modifiedApache 2.4 mod_cache + mod_cache_disk + modjk:304 未修改,但内容长度已修改
【发布时间】:2016-07-11 02:45:49
【问题描述】:

我对 mod_cache 快疯了!

我目前的设置:

Ubuntu 上的 Apache 2.4:
- mpm_worker
- mod_jk
- mod_cache
- mod_cache_disk
- mod_expires
- mod_deflate

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 没有失败,但访问抛出浏览器失败。

有人知道吗?

谢谢 陶兰特

【问题讨论】:

    标签: apache caching mod-jk apache2.4 mod-cache


    【解决方案1】:

    我认为,mod_cache bug 56881 涵盖了这一点,它已在 Apache 2.4.11 中修复。

    【讨论】:

      猜你喜欢
      • 2012-08-18
      • 1970-01-01
      • 2011-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多