Authored by hf

do add home page browser cache

... ... @@ -412,4 +412,34 @@ class AbstractAction extends Controller_Abstract
$this->_view->assign('sideNav', \Index\SideModel::getLeftNav($guangChoosed));
}
/**
* 设置最后修改时间
*
* @param string $modifiedTime 修改时间戳
* @param type $notModifiedExit 是否在没有修改时返回304状态
* @return void
*/
public static function setLastModified($modifiedTime, $notModifiedExit = true)
{
$modifiedTime = date('D, d M Y H:i:s ', $modifiedTime) . 'GMT';
if ($notModifiedExit && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $modifiedTime == $_SERVER['HTTP_IF_MODIFIED_SINCE']) {
header('HTTP/1.1 304 Not Modified');
exit();
}
header('Last-Modified: ' . $modifiedTime);
}
/**
* 设置浏览器的缓存
*
* @param int $seconds 单位是秒
* @return void
*/
public static function setExpires($seconds = 180)
{
$time = date('D, d M Y H:i:s ', time() + $seconds) . 'GMT';
header('Expires: ' . $time);
}
}
... ...
... ... @@ -17,6 +17,9 @@ class BoysController extends AbstractAction
if (null !== $this->get('go')) {
// 先检查COOKIE是否有访问过, 有则跳转到相应的频道页
Index\HomeModel::goSwitchChannel();
} else {
// 设置客户端浏览器1分钟内不改变
$this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y')));
}
// 设置COOKIE标识用户访问过该页面了
... ...
... ... @@ -14,6 +14,9 @@ class GirlsController extends AbstractAction
*/
public function indexAction()
{
// 设置客户端浏览器1分钟内不改变
$this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y')));
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_GIRLS);
... ...
... ... @@ -17,6 +17,9 @@ class IndexController extends AbstractAction
if (null !== $this->get('go')) {
// 先检查COOKIE是否有访问过, 有则跳转到相应的频道页
Index\HomeModel::goSwitchChannel();
} else {
// 设置客户端浏览器1小时内不改变
$this->setLastModified(mktime(date('H'), 0, 0, date('n'), date('j'), date('Y')));
}
// 渲染模板
... ...
... ... @@ -14,6 +14,9 @@ class KidsController extends AbstractAction
*/
public function indexAction()
{
// 设置客户端浏览器1分钟内不改变
$this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y')));
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_KIDS);
... ...
... ... @@ -14,6 +14,9 @@ class LifestyleController extends AbstractAction
*/
public function indexAction()
{
// 设置客户端浏览器1分钟内不改变
$this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y')));
// 设置COOKIE标识用户访问过该页面了
Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_LIFESTYLE);
... ...
... ... @@ -16,6 +16,9 @@ class SearchController extends AbstractAction
*/
public function indexAction()
{
// 设置客户端浏览器1小时内不改变
$this->setLastModified(mktime(date('H'), 0, 0, date('n'), date('j'), date('Y')));
$this->setNavHeader('搜索', true, SITE_MAIN);
//$this->_view->html('search');
... ... @@ -207,7 +210,7 @@ class SearchController extends AbstractAction
'discount' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,
'page' => FILTER_VALIDATE_INT, ), false);
'page' => FILTER_VALIDATE_INT,), false);
// 转义分类
if (isset($condition['sort'])) {
$condition['sort'] = rawurldecode($condition['sort']);
... ... @@ -246,7 +249,6 @@ class SearchController extends AbstractAction
// $data = Product\ListModel::getClassData($condition);
$data = Product\SearchModel::getSearchData($condition);
} while (false);
if (empty($data['new'])) {
... ... @@ -309,7 +311,7 @@ class SearchController extends AbstractAction
*
* @return array 模糊搜索的结果
*/
/*public function fuzzysearch()
/* public function fuzzysearch()
{
if ($this->isAjax()) {
$keyword = $this->post('keyword', '');
... ... @@ -318,6 +320,5 @@ class SearchController extends AbstractAction
$this->echoJson($result);
}
}*/
} */
}
... ...
... ... @@ -114,6 +114,9 @@ class OptController extends AbstractAction
/* 检查用户是否登录 */
$uid = $this->getUid();
if (!$uid) {
$uid = $this->getSession('uid');
}
if (empty($uid) || !is_numeric($uid)) {
break;
}
... ...
... ... @@ -99,6 +99,8 @@ class PlusstarController extends AbstractAction
}
$uid = $this->get('uid');
$udid = $this->get('udid');
$this->setSession('uid', $uid);
}
// 从Cookie获取
else {
... ...