简体   繁体   English

mod_cache + ETag:Apache不回复304给客户端

[英]mod_cache + ETag: Apache does not reply 304 to client

I have a problem with mod_cache and ETags. 我有mod_cache和ETags的问题。 Here's my scenario: 这是我的情景:

Environment: Firefox, Apache 2.2.22 (Mac OSX default), any Web App, Apache is a proxy to the Web App 环境:Firefox,Apache 2.2.22(Mac OSX默认),任何Web App,Apache都是Web App的代理

Initial State: 初始状态:

  • Browser has an (expired) cache version of doc /aaa, ETag=123 浏览器有一个(过期的)缓存版本的doc / aaa,ETag = 123
  • Apache has an (expired) cache version of doc /aaa, ETag=123 Apache有一个(过期的)缓存版本的doc / aaa,ETag = 123

Scenario: 场景:

  • Browser requests /aaa, If-None-Match: 123 浏览器请求/ aaa,If-None-Match:123
  • Apache requests /aaa, If-none-Match: 123 from Web App Apache在Web App中请求/ aaa,If-none-Match:123
  • Web App returns 304 Web App返回304
  • Apache returns his cached version to the Browser (200) Apache将其缓存版本返回到浏览器(200)

Shouldn't Apache return 304 to the Browser? Apache不应该向浏览器返回304吗?

Additional Info: 附加信息:

  • if Apache has no cached version of /aaa, he forwards the ETag to Web App, get 304, and returns 304 to the Browser 如果Apache没有缓存版本的/ aaa,他会将ETag转发到Web App,获取304,然后返回304到浏览器
  • working with Last-Modified/If-Modified-Since instead of ETags works (after getting 304 from the Web App, Apache returns 304 to the Browser) 使用Last-Modified / If-Modified-Since而不是ETags工作(从Web App获得304后,Apache将304返回到浏览器)

A much simpler scenario: 一个更简单的场景:

  • Apache version is not expired (ETag: 123) - he doesn't need to get a refresh from Web App Apache版本未过期(ETag:123) - 他不需要从Web App刷新
  • GET /aaa, If-None-Match: 123 GET / aaa,If-None-Match:123
  • Response: 200 (instead of 304?) 回复:200(而不是304?)

apache conf apache conf

CacheRoot /private/var/log/apache2/cache/
CacheEnable disk /
CacheDirLevels 5
CacheDirLength 3
CacheIgnoreCacheControl On
CacheIgnoreHeaders Set-Cookie

<Proxy *>
   Order deny,allow
   Allow from all
</Proxy>

ProxyPass / ajp://localhost:8009/ retry=0
ProxyPassReverse / ajp://localhost:8009/
ProxyPreserveHost on

Request/Response Headers: 请求/响应标题:

GET / HTTP/1.1
Accept: */*
If-None-Match: 123456

HTTP/1.1 200 OK
Date: Tue, 01 Oct 2013 14:01:16 GMT
ETag: 123456
Expires: Tue, 01 Oct 2013 14:30:55 GMT
Cache-Control: max-age=1800
Content-Language: en-US
Age: 21
Content-Length: 20186
Content-Type: text/html;charset=UTF-8

According to protocol specification the If-None-Match header should be wrapped with " . 根据协议规范 ,If-None-Match标头应包含

Try sending: 尝试发送:

If-None-Match: "123"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM