json 반환시 캐싱하지 않도록 설정.

연감용 json 반환에는 캐싱할 수 있도록 설정
This commit is contained in:
2018-02-02 09:36:49 +09:00
parent 75fb281264
commit 9ef4e2debb
2 changed files with 17 additions and 2 deletions
+8 -1
View File
@@ -33,4 +33,11 @@ else{
$post['month'] = null;
}
returnJson(getWorldMap($post));
$result = getWorldMap($post);
if($post['year'] && $post['month'] && $result['result']){
//연감 자료는 캐싱 가능
returnJson($result, false);
}
else{
returnJson($result);
}
+9 -1
View File
@@ -137,8 +137,16 @@ function Error($message, $url="") {
exit;
}
function returnJson($value, $pretty = false, $die = true){
function returnJson($value, $noCache = true, $pretty = false, $die = true){
header('Content-Type: application/json');
if($noCache){
header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', FALSE);
header('Pragma: no-cache');
}
if($pretty){
$flag = JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT;
}