Merge selected commits from branch 'wkpark@varnish_cache'

This commit is contained in:
Kijin Sung 2015-07-12 14:08:39 +09:00
commit 0bbbc88377
3 changed files with 23 additions and 17 deletions

View file

@ -358,6 +358,7 @@ class Context
}
else
{
$this->isSessionStarted = FALSE;
$_SESSION = array();
}
@ -475,6 +476,26 @@ class Context
session_write_close();
}
/**
* set Cache-Control header
*
* @return void
*/
function setCacheControl($public = 'public', $nocache = false)
{
is_a($this, 'Context') ? $self = $this : $self = self::getInstance();
$public = !empty($public) ? $public.', ' : '';
header("Cache-Control: ".$public."must-revalidate, post-check=0, pre-check=0");
if ($nocache)
{
header("Cache-Control: no-store, no-cache, must-revalidate", false);
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Pragma: no-cache");
}
}
/**
* Load the database information
*

View file

@ -324,11 +324,6 @@ class DisplayHandler extends Handler
function _printXMLHeader()
{
header("Content-Type: text/xml; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
@ -338,11 +333,6 @@ class DisplayHandler extends Handler
function _printHTMLHeader()
{
header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**
@ -352,11 +342,6 @@ class DisplayHandler extends Handler
function _printJSONHeader()
{
header("Content-Type: text/html; charset=UTF-8");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
/**

View file

@ -123,13 +123,13 @@ class Mobile
setcookie("mobile", 'true', 0, $xe_web_path);
}
}
elseif($_COOKIE['mobile'] != 'false')
elseif(isset($_COOKIE['mobile']) && $_COOKIE['mobile'] != 'false')
{
$_COOKIE['mobile'] = 'false';
setcookie("mobile", 'false', 0, $xe_web_path);
}
if($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
if(isset($_COOKIE['mobile']) && $_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
{
setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path);
}