do add home page browser cache
Showing
9 changed files
with
56 additions
and
5 deletions
@@ -412,4 +412,34 @@ class AbstractAction extends Controller_Abstract | @@ -412,4 +412,34 @@ class AbstractAction extends Controller_Abstract | ||
412 | $this->_view->assign('sideNav', \Index\SideModel::getLeftNav($guangChoosed)); | 412 | $this->_view->assign('sideNav', \Index\SideModel::getLeftNav($guangChoosed)); |
413 | } | 413 | } |
414 | 414 | ||
415 | + /** | ||
416 | + * 设置最后修改时间 | ||
417 | + * | ||
418 | + * @param string $modifiedTime 修改时间戳 | ||
419 | + * @param type $notModifiedExit 是否在没有修改时返回304状态 | ||
420 | + * @return void | ||
421 | + */ | ||
422 | + public static function setLastModified($modifiedTime, $notModifiedExit = true) | ||
423 | + { | ||
424 | + $modifiedTime = date('D, d M Y H:i:s ', $modifiedTime) . 'GMT'; | ||
425 | + if ($notModifiedExit && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $modifiedTime == $_SERVER['HTTP_IF_MODIFIED_SINCE']) { | ||
426 | + header('HTTP/1.1 304 Not Modified'); | ||
427 | + exit(); | ||
428 | + } | ||
429 | + header('Last-Modified: ' . $modifiedTime); | ||
430 | + } | ||
431 | + | ||
432 | + /** | ||
433 | + * 设置浏览器的缓存 | ||
434 | + * | ||
435 | + * @param int $seconds 单位是秒 | ||
436 | + * @return void | ||
437 | + */ | ||
438 | + public static function setExpires($seconds = 180) | ||
439 | + { | ||
440 | + $time = date('D, d M Y H:i:s ', time() + $seconds) . 'GMT'; | ||
441 | + | ||
442 | + header('Expires: ' . $time); | ||
443 | + } | ||
444 | + | ||
415 | } | 445 | } |
@@ -17,6 +17,9 @@ class BoysController extends AbstractAction | @@ -17,6 +17,9 @@ class BoysController extends AbstractAction | ||
17 | if (null !== $this->get('go')) { | 17 | if (null !== $this->get('go')) { |
18 | // 先检查COOKIE是否有访问过, 有则跳转到相应的频道页 | 18 | // 先检查COOKIE是否有访问过, 有则跳转到相应的频道页 |
19 | Index\HomeModel::goSwitchChannel(); | 19 | Index\HomeModel::goSwitchChannel(); |
20 | + } else { | ||
21 | + // 设置客户端浏览器1分钟内不改变 | ||
22 | + $this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y'))); | ||
20 | } | 23 | } |
21 | 24 | ||
22 | // 设置COOKIE标识用户访问过该页面了 | 25 | // 设置COOKIE标识用户访问过该页面了 |
@@ -14,6 +14,9 @@ class GirlsController extends AbstractAction | @@ -14,6 +14,9 @@ class GirlsController extends AbstractAction | ||
14 | */ | 14 | */ |
15 | public function indexAction() | 15 | public function indexAction() |
16 | { | 16 | { |
17 | + // 设置客户端浏览器1分钟内不改变 | ||
18 | + $this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y'))); | ||
19 | + | ||
17 | // 设置COOKIE标识用户访问过该页面了 | 20 | // 设置COOKIE标识用户访问过该页面了 |
18 | Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_GIRLS); | 21 | Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_GIRLS); |
19 | 22 |
@@ -17,6 +17,9 @@ class IndexController extends AbstractAction | @@ -17,6 +17,9 @@ class IndexController extends AbstractAction | ||
17 | if (null !== $this->get('go')) { | 17 | if (null !== $this->get('go')) { |
18 | // 先检查COOKIE是否有访问过, 有则跳转到相应的频道页 | 18 | // 先检查COOKIE是否有访问过, 有则跳转到相应的频道页 |
19 | Index\HomeModel::goSwitchChannel(); | 19 | Index\HomeModel::goSwitchChannel(); |
20 | + } else { | ||
21 | + // 设置客户端浏览器1小时内不改变 | ||
22 | + $this->setLastModified(mktime(date('H'), 0, 0, date('n'), date('j'), date('Y'))); | ||
20 | } | 23 | } |
21 | 24 | ||
22 | // 渲染模板 | 25 | // 渲染模板 |
@@ -14,6 +14,9 @@ class KidsController extends AbstractAction | @@ -14,6 +14,9 @@ class KidsController extends AbstractAction | ||
14 | */ | 14 | */ |
15 | public function indexAction() | 15 | public function indexAction() |
16 | { | 16 | { |
17 | + // 设置客户端浏览器1分钟内不改变 | ||
18 | + $this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y'))); | ||
19 | + | ||
17 | // 设置COOKIE标识用户访问过该页面了 | 20 | // 设置COOKIE标识用户访问过该页面了 |
18 | Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_KIDS); | 21 | Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_KIDS); |
19 | 22 |
@@ -14,6 +14,9 @@ class LifestyleController extends AbstractAction | @@ -14,6 +14,9 @@ class LifestyleController extends AbstractAction | ||
14 | */ | 14 | */ |
15 | public function indexAction() | 15 | public function indexAction() |
16 | { | 16 | { |
17 | + // 设置客户端浏览器1分钟内不改变 | ||
18 | + $this->setLastModified(mktime(date('H'), date('i'), 0, date('n'), date('j'), date('Y'))); | ||
19 | + | ||
17 | // 设置COOKIE标识用户访问过该页面了 | 20 | // 设置COOKIE标识用户访问过该页面了 |
18 | Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_LIFESTYLE); | 21 | Index\HomeModel::setSwitchToCookie(Index\HomeModel::COOKIE_NAME_LIFESTYLE); |
19 | 22 |
@@ -16,6 +16,9 @@ class SearchController extends AbstractAction | @@ -16,6 +16,9 @@ class SearchController extends AbstractAction | ||
16 | */ | 16 | */ |
17 | public function indexAction() | 17 | public function indexAction() |
18 | { | 18 | { |
19 | + // 设置客户端浏览器1小时内不改变 | ||
20 | + $this->setLastModified(mktime(date('H'), 0, 0, date('n'), date('j'), date('Y'))); | ||
21 | + | ||
19 | $this->setNavHeader('搜索', true, SITE_MAIN); | 22 | $this->setNavHeader('搜索', true, SITE_MAIN); |
20 | 23 | ||
21 | //$this->_view->html('search'); | 24 | //$this->_view->html('search'); |
@@ -207,7 +210,7 @@ class SearchController extends AbstractAction | @@ -207,7 +210,7 @@ class SearchController extends AbstractAction | ||
207 | 'discount' => FILTER_DEFAULT, | 210 | 'discount' => FILTER_DEFAULT, |
208 | 'gender' => FILTER_DEFAULT, | 211 | 'gender' => FILTER_DEFAULT, |
209 | 'p_d' => FILTER_DEFAULT, | 212 | 'p_d' => FILTER_DEFAULT, |
210 | - 'page' => FILTER_VALIDATE_INT, ), false); | 213 | + 'page' => FILTER_VALIDATE_INT,), false); |
211 | // 转义分类 | 214 | // 转义分类 |
212 | if (isset($condition['sort'])) { | 215 | if (isset($condition['sort'])) { |
213 | $condition['sort'] = rawurldecode($condition['sort']); | 216 | $condition['sort'] = rawurldecode($condition['sort']); |
@@ -246,7 +249,6 @@ class SearchController extends AbstractAction | @@ -246,7 +249,6 @@ class SearchController extends AbstractAction | ||
246 | // $data = Product\ListModel::getClassData($condition); | 249 | // $data = Product\ListModel::getClassData($condition); |
247 | 250 | ||
248 | $data = Product\SearchModel::getSearchData($condition); | 251 | $data = Product\SearchModel::getSearchData($condition); |
249 | - | ||
250 | } while (false); | 252 | } while (false); |
251 | 253 | ||
252 | if (empty($data['new'])) { | 254 | if (empty($data['new'])) { |
@@ -309,7 +311,7 @@ class SearchController extends AbstractAction | @@ -309,7 +311,7 @@ class SearchController extends AbstractAction | ||
309 | * | 311 | * |
310 | * @return array 模糊搜索的结果 | 312 | * @return array 模糊搜索的结果 |
311 | */ | 313 | */ |
312 | - /*public function fuzzysearch() | 314 | + /* public function fuzzysearch() |
313 | { | 315 | { |
314 | if ($this->isAjax()) { | 316 | if ($this->isAjax()) { |
315 | $keyword = $this->post('keyword', ''); | 317 | $keyword = $this->post('keyword', ''); |
@@ -318,6 +320,5 @@ class SearchController extends AbstractAction | @@ -318,6 +320,5 @@ class SearchController extends AbstractAction | ||
318 | 320 | ||
319 | $this->echoJson($result); | 321 | $this->echoJson($result); |
320 | } | 322 | } |
321 | - }*/ | ||
322 | - | 323 | + } */ |
323 | } | 324 | } |
@@ -114,6 +114,9 @@ class OptController extends AbstractAction | @@ -114,6 +114,9 @@ class OptController extends AbstractAction | ||
114 | /* 检查用户是否登录 */ | 114 | /* 检查用户是否登录 */ |
115 | $uid = $this->getUid(); | 115 | $uid = $this->getUid(); |
116 | if (!$uid) { | 116 | if (!$uid) { |
117 | + $uid = $this->getSession('uid'); | ||
118 | + } | ||
119 | + if (empty($uid) || !is_numeric($uid)) { | ||
117 | break; | 120 | break; |
118 | } | 121 | } |
119 | 122 |
@@ -99,6 +99,8 @@ class PlusstarController extends AbstractAction | @@ -99,6 +99,8 @@ class PlusstarController extends AbstractAction | ||
99 | } | 99 | } |
100 | $uid = $this->get('uid'); | 100 | $uid = $this->get('uid'); |
101 | $udid = $this->get('udid'); | 101 | $udid = $this->get('udid'); |
102 | + | ||
103 | + $this->setSession('uid', $uid); | ||
102 | } | 104 | } |
103 | // 从Cookie获取 | 105 | // 从Cookie获取 |
104 | else { | 106 | else { |
-
Please register or login to post a comment