내 이미지의 캐시 옵션을 설정하는 동안 struts2의 이상한 버리기 동작이 있습니다. 제가 DB에서 이미지를 넣을려고스트럿츠 2 캐시 헤더를 버림
특별한 결과 유형은 다음과 같이 렌더링 내가 사용하는 이미지 (http://struts.apache.org/2.x/docs/how-can-we-display-dynamic-or-static-images-that-can-be-provided-as-an-array-of-bytes.html)을 렌더링하기 위해 클라이언트 측 에 캐시합니다 :
public void execute(ActionInvocation invocation) throws Exception {
...//some preparation
HttpServletResponse response = ServletActionContext.getResponse();
HttpServletRequest request = ServletActionContext.getRequest();
ServletOutputStream os = response.getOutputStream();
try
{
byte[] imageBytes = action.getImage();
response.setContentType("image/gif");
response.setContentLength(imageBytes.length);
//I want cache up to 10 min
Date future = new Date(((new Date()).getTime() + 1000 * 10*60l));
;
response.addDateHeader("Expires", future.getTime());
response.setHeader("Cache-Control", "max-age=" + 10*60 + "");
response.addHeader("cache-Control", "public");
response.setHeader("ETag", request.getRequestURI());
os.write(imageBytes);
}
catch(Exception e)
{
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
os.flush();
os.close();
}
그러나 이미지는 페이지에 내장되어 그것은 항상 다시로드 (방화범 코드 (200)를 보여줍니다), 및 기간 제한 없음하지도 않으며, 최대 사용 기간은 내가 URL에 문제가있을 수 있습니다이 dissapered 왜 아무 생각이,이 없다
Host localhost:9090
Accept image/png,image/*;q=0.8,*/*;q=0.5
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
Referer http://localhost:9090/web/result?matchId=1
Cookie JSESSIONID=4156BEED69CAB0B84D950932AB9EA1AC;
If-None-Match /web/_srv/teamcolor
Cache-Control max-age=0
헤더
에 제시되어있다? 매개 변수가있는 양식입니다.http://localhost:9090/web/_srv/teamcolor?loginId=3
결과는 동일합니다. 즉, 인터셉터도 결과 유형도 헤더에 영향을주지 않습니다. 그것은 스트럿츠에 의해 운반됩니다. – Dewfy