【发布时间】:2013-11-21 09:09:16
【问题描述】:
我正在编写一个 Java 网络服务,用于网络优化方面的培训。我的网络服务发送的响应将在 365 天后过期
@Path("cache2")
public class WsCache {
@GET
@Produces("application/json")
public Response expires(){
System.out.println("Expires in 365 days");
String later = getDaysAfterHttpDate(365);
return Response.ok("{Hello:hello}").header("Expires",later).build();
}
}
问题是 Chrome 或 Firefox 使用缓存控制发出请求:
GET /fora-comments-ejb/api/cache2 HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html...
User-Agent: Mozilla/5.0 ...
Accept-Encoding: gzip,deflate,sdch
Accept-Language: fr-FR,fr;...
因为max-age 的任何值都会覆盖Expires,有没有办法说Firefox/Chrome 不对第二个请求使用缓存控制?
【问题讨论】:
标签: http-headers cache-control