ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • JSP에서 No-Cache 설정하는 방법
    JSP 2016. 3. 16. 14:53

    웹개발 하다보면 캐쉬된 페이지때문에 가끔 웹브라우저가 재시동하거나, 웹서버를 재시동하는 경우가 있었을 것이다. 그런 경우 캐쉬에서 불러오는 것이 아니라 항상 최신의 페이지를 보여주도록 하는 방법입니다. 데이터가 넘어가는 경우에만 '만료된 페이지입니다' 라는 메시지를 보여주게 됩니다.

    다음은 각각의 케이스별 No-Cache 설정방법입니다.

    HTML인 경우

    <META http-equiv="Expires" content="-1">
    <META http-equiv="Pragma" content="no-cache">
    <META http-equiv="Cache-Control" content="No-Cache">

    ASP인 경우 
    <% 
    Response.Expires = 0 
    Response.AddHeader "Pragma","no-cache" 
    Response.AddHeader "Cache-Control","no-cache,must-revalidate" 
    %> 

    JSP인 경우 
    <% 
    response.setHeader("Cache-Control","no-store"); 
    response.setHeader("Pragma","no-cache"); 
    response.setDateHeader("Expires",0); 
    if (request.getProtocol().equals("HTTP/1.1"))
            response.setHeader("Cache-Control", "no-cache");
    %> 

    PHP인 경우 
    <? 
    header("Pragma: no-cache"); 
    header("Cache-Control: no-cache,must-revalidate"); 
    ?>



    'JSP' 카테고리의 다른 글

    Listener 란?  (0) 2016.08.18
    [iBatis/myBatis] #와 $의 차이점  (0) 2016.07.15
    EL에서 #과 $의 차이점  (0) 2016.07.15
    EL 줄바꿈처리  (0) 2016.07.05
    웹프로그래밍 언어별 Referer  (0) 2016.03.16

    댓글

Designed by Tistory.