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

问题描述 投票:0回答:2

我对 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
2个回答
0
投票

我认为,这已被 mod_cache bug 56881 覆盖,已在 Apache 2.4.11 中修复。


0
投票

其原因就在这行后面:

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

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

© www.soinside.com 2019 - 2024. All rights reserved.