Cache Control은 리소스의 캐쉬를 브라우저에서 얼마나 보관하는지를 지정해주는 요소이다. max-age 속성에 초 단위로 기록된 시간만큼 브라우저에서 리소스를 보관하게 된다. 같은 URL로 리소스 대한 호출이 다시 일어 났을 때, max-age만큼 경과시간을 확인하고 max-age만큼의 시간이 흐르지 않았을 때는 웹 서버에 리소스를 요청하지 않고 캐쉬에 있는 리소스를 사용하게 된다.

header('Cache-Control: max-age=86400');
header('Content-Type: image/jpg');
if(isset($_GET['base64'])) {
	$out = base64_encode(file_get_contents($path));
	header('Content-Length: '.strlen($out));
	print $out;
} else {
	header('Content-Length: '.filesize($path));
	print file_get_contents($path);
}
Posted by 강부자아들
,