티스토리 뷰

09. IT

Https 에서의 No-cache 문제

오뉴 2013. 6. 18. 18:14

http://crown0047.egloos.com/1163168 퍼옴

 

예전에 1.4 자바로 개발 중에 cache에는 저장하지 않는 명령어를 위해


response.setHeader("Pragma", "no-cache");

if(request.getProtocol().equals("HTTP/1.1"))
{
response.setHeader("Cache-Control", "no-cache");
}

[출처] Pragma와 Cache-Control|작성자 semi7623
참고주소 :
http://blog.naver.com/semi7623?Redirect=Log&logNo=100005637477

이와 같은 소스를 개발하여야했습니다.

한마디로 response.setHeader("Pragma","no-cache");
는 HTTP 1.0 에서 동작하는 거라서 현재 익스플로러 1.1 과는 연관없다고 판단했었습니다.

근데 요즘 브라우저는 두 개 다 인식하나 봅니다.

response.setHeader("Pragma", "no-cache");

만 설정하더라도 인식합니다. 참 신기합니다.

여하튼 해당 소스에서 문제가 발생했습니다.

ssl 을 이용하여 https url로 구성된 웹사이트에서 파일 다운로드시 IE에서만 "다운로드 할 수 없습니다." 라는 오류 메시지가 내는 문제인데요.

microsoft 고객 센터에 이미 언급되었던 문제점이며, 원인으로는 아래와 같습니다.

- SSL 을 통한 Internet Explorer 파일 다운로드가 "No-Cache" 헤더에서 작동하지 않는다.

해결 방안으로는 서버가 Cache-Control 헤더로 No Store 나 No Cache 를 보내지 않도록 바꿔주어야 합니다.

- 현재 문제가 되고 있는 곳은 위젯 상세 화면에서 CSV EXPORT 와 ZIP EXPORT 기능입니다. 두 기능 모두 Pragma no-cache 가 설정되어 있습니다.

- 설정되어 있는 no-cache 를 제거하면 정상적으로 파일 다운로드가 동작하는 것을 확인했습니다.


참고 : Microsoft에 언급되어 있는 페이지입니다.

http://support.microsoft.com/kb/812935, http://support.microsoft.com/kb/323308

HTTPS 에서 no-cache 나 max-age=0 을 사용할 경우 특정파일을 로딩하는데 문제가 있는 것으로 알고 있습니다.

캐시를 해도 되는 경우라면 단순히 해당 헤더를 제거하면 되지만

캐시를 하면 안되는 경우에는 하기와 같이 설정하여 우회해야합니다.

if("csv".equals(file_type))

{

response.setContentType("text/csv;charset=UTF-8");

response.setHeader("Content-Disposition", "attachment;filename=" + fileName+".csv");

response.setHeader("Pragma","no-cache");

response.setHeader("Expires","0");

}

else if("zip".equals(file_type))

{

response.setContentType("application/x-unknown-content-type");

response.setHeader("Content-Disposition", "attachment;filename=" + fileName+".zip");

response.setHeader("Content-Encoding" , "compress");

response.setHeader("Pragma","no-cache");

response.setHeader("Expires","0");

}

기존에 구현된 로직입니다.

if("csv".equals(file_type))

{

response.setContentType("text/csv;charset=UTF-8");

response.setHeader("Content-Disposition", "attachment;filename=" + fileName+".csv");

response.setDateHeader("Expires", 0);

response.setHeader("Pragma", "no-store, no-cache, must-revalidate");

}

else if("zip".equals(file_type))

{

response.setContentType("application/x-unknown-content-type");

response.setHeader("Content-Disposition", "attachment;filename=" + fileName+".zip");

response.setHeader("Content-Encoding" , "compress");

response.setDateHeader("Expires", 0);

response.setHeader("Pragma", "no-store, no-cache, must-revalidate");

}

이렇게 수정하여 테스트 완료되었습니다.

참고 page : http://www.http-stats.com/Pragma

Common Pragma header values:

  • Pragma: no-cache
  • Pragma: no-cache, xResetStrm=1
  • Pragma: No-cache
  • Pragma: cache
  • Pragma: No-Cache
  • Pragma: private
  • Pragma: public
  • Pragma: no-store
  • Pragma: no-store, no-cache, must-revalidate
  • Pragma: no cache
  • Pragma: NO-CACHE
  • Pragma: Private
  • Pragma: no-cache, no-cache
  • Pragma: no-cash
  • Pragma: no-chache
  • Pragma: no-store,no-cache
  • Pragma: no_cache
  • Pragma: nocache

ps . 근데 풀리지 않는 의문은 1.1 은 Cache-Content 아니였는 가 하는 의문이지만,
테스트 시 문제없기 때문에 그대로 넘어갔습니다.

댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함