Skip to main content

Posts

Showing posts from May 25, 2014

Apache에서 response header를 포함하여 캐싱하기

Apache의 mod_asis 모듈 정적 파일만을 캐싱하고자 하는 경우는, Apache의 Alias로 대응하면 된다. 그러나 가끔 HTTP의 Response Header 정보도 Application에 반환해야 하는 경우가 있다. 이 때 mod_asis를 활용하여, 캐싱할 수 있다. 1) mod_asis 설정 httpd.conf 등의 apache 설정 파일에 아래 내용을 추가한다. LoadModule asis_module lib/modules/mod_asis.so         AddHandler send-as-is asis         RewriteEngine On         RewriteRule ^특정URI$ /filepath/filename.asis [NC,L] 파일 확장자를 asis로 해두는 것이 좋다. 2) response 용 파일 만들기 위에서의 filename.asis의 내용은 다음과 같이 curl --head로 취득한 Response Header 내용과 response body으로 구성하면 된다. 주의점: http://httpd.apache.org/docs/2.2/mod/mod_asis.html의 Notes란에서 언급하듯, Server: 와 Date: 헤더는 삭제해야 한다. 이 정보는 Apache가 알아서 생성해주는 정보이기 때문이다. 이뿐만 아니라 , Status 헤더도 없어도 동작하는데 문제 없다. HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Embedded-Crowd-Version: Crowd/2.4.2 X-Crowd-User-Management-Version: 1.2 Set-Cookie: JSESSIONID=D05FCBE668C69632C3E9FAA6FD14C1C6; Path=/crowd Content-Type: application/xml Content-Length: 153 Date: Fri, 30 May 2014 07:26:43