메뉴 건너뛰기

2016.12.22 22:19

response.setHeader

조회 수 7358 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

최신의 페이지를 캐쉬 없이 노출을 원할 경우

 

String httpVersion=request.getProtocol();
if(httpVersion.equals("HTTP/1.0")) {
    response.setDateHeader("Expires",-1);
    response.setHeader("Pragma","no-cache");
} else if(httpVersion.equals("HTTP/1.1")) {
    response.setHeader("Cache-Control","no-cache");
}

 

 

 

 

http://www.ehow.com/how_5244764_use-response-setheader.html


Response headers are objects that send servers information about the request. SetHeader in Java is a method used by developers to set configurations for content type. For instance, you can tell the server that the request is an XML. This helps validate the output and eliminate errors.


Response header 는 요청에 대한 서버 정보를 주는 객체다. 자바의 SetHeader 컨텐츠 타입 설정을 맞추기위해 개발자들에 의해 사용되는 방법이다.  예를 들어 서버에 요청이 XML (타입) 이라고 말할 수 있다. 그러면 이것이 결과물의 유효성과 오류를 제가하는데 도움을 줄 것이다.

 

> Step 1
Use setheaders to control the cache of the page. The cache is how long the user's browser saves the page content without making a new call to the server. Use the "Expires" setting to control the cache. This is a good setting for pages that are updated frequently. This also sets the proxy server from cache setting:
response.setHeader("Expires", "Thursday, February 15 2009 12:00:00 GMT");

페이지의 캐쉬를 통제키 위해 setheader를 사용한다. 캐쉬는 서버로의 새로운 호출없이 사용자의 브라우저가 저장하고 있는 페이지의 내용이다. ( 캐쉬를 통제하기위해 "Expires" 를 사용한다. 이것은 자주 변경되는 페이지를 위한 좋은 방법이다. 이것을 프록시 서버로부터 캐쉬를 설정한다.

 

> Step 2
Set the content type. This tells the server what kind of coding is used on the site. The following code sets the content type to HTML:
response.setContentType("text/html");

컨텐츠 타입을 설정한다. 이것은 사이트에 사용된 코딩의 종류가 무엇인지에 대해 알려준다. 다음 코드는 컨텐츠 타입을 HTML 로 설정한것이다.

 

> Step 3
Prevent the browser from caching the page. The following code sets "No Cache" properties:
response.setHeader("Cache-Control","no-cache")

다음의 코드 "No Cache" 속성은 브라우저가 페이지로부터 캐싱을 막는다.

 

> Step 4
Load or redirect to another page in a certain amount of time. This setting tells the browser to refresh the page in "x" seconds. The following code sets the refresh setting to 20 seconds:
response.setHeader("Refresh", "20")

일정 시간에 사이트를 불러오거나 다른 사이트로 이동한다. 이 설정은 브라우저에게 x 초(후)에 refresh하라고 전달한다. 다음코드는 20초로 refresh 시간을 설정했다.

 

> Step 5
Set a cookie on the user's browser using the addCookie method. The following command sets a cookie on the user's computer for saved content and settings:
response.addCookie ("MyCookie", "myValue")

addCookie 메소드를 이용하여 사용자 브라우저의 쿠키를 설정할 수 있다. 다음 명령은 사용자 컴퓨터의 저장된 컨텐츠와 설정들을 위해 쿠키를 설정한다.


  1. select 당일 날짜 출력

  2. No Image 22Dec
    by 조쉬
    2016/12/22 Views 7358 

    response.setHeader

  3. No Image 26Mar
    by
    2021/03/26 Views 1438 

    opener 값전달, 함수실행.(자식창에서 부모창으로 값전달, 함수실행)

  4. No Image 21Sep
    by
    2016/09/21 Views 7001 

    onkeypress 키보드 이벤트 처리하는 법 – text, textarea

  5. No Image 20Jan
    by
    2023/01/20 Views 134 

    Node.js와 npm(+ npx)의 개념

  6. No Image 19Jun
    by
    2015/06/19 Views 9406 

    location.href 로 새창 여는 방법 (target=_blank 효과)

  7. Location 객체 - URL 파싱 - URL에서 전달인자 추출하기 함수 작성

  8. No Image 29Aug
    by
    2018/08/29 Views 1622 

    key pressing 누르거나 클릭중인 이벤트 예제

  9. JSON API - JSON.parse(), JSON.stringify() ( json 형태의 문자열을 JSON객체로 , JSON객체를 문자열로 )

  10. jQuery 이미지 슬라이드 오버시 큰이미지 보여주기 소스

  11. No Image 27Oct
    by
    2018/10/27 Views 1732 

    jQuery 엘리먼트 선택

  12. No Image 06Apr
    by
    2015/04/06 Views 11698 

    jquery 메뉴 - 아래로 한번에 전체가 펼처짐

  13. No Image 11Sep
    by
    2016/09/11 Views 5518 

    jquery 기본 엘리먼트 속성제어방법

  14. No Image 01Sep
    by
    2016/09/01 Views 7277 

    jquery offset()을 이용한 부드러운 스크롤 이동

  15. jqgrid 이용한 그리드 활용하기

  16. JDK6 (Java SE Development Kit 6)이하 버전 다운로드 주소

  17. No Image 17Nov
    by
    2016/11/17 Views 9821 

    javascript 화면 캡쳐

  18. No Image 28Sep
    by
    2018/09/28 Views 3252 

    JavaScript 출생년도에 따른 나이 계산 자바스크립트

  19. No Image 01Mar
    by
    2014/03/01 Views 32585 

    javascript 인쇄 미리보기, 출력, 페이지 설정 등

  20. No Image 21Sep
    by
    2016/09/21 Views 5657 

    javascript 에서 제공하는 3가지 종류의 팝업박스

Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 Next
/ 13

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved