Changeset 80713b0054beb5197e1a9a4347a066496a08d939
- Timestamp:
- 12/02/09 21:24:04 (3 years ago)
- Author:
- Leo 'costela' Antunes <leo@…>
- Parents:
- e17861cf54208dc1c6dc231687cafc3ac2321d7d
- git-committer:
- Leo 'costela' Antunes <leo@…> (12/02/09 21:24:04)
- Message:
-
minor reworking of the checkFreshness code
git-svn-id: http://svn.costela.net/guck/trunk@51 0b27b881-053d-0410-9699-9726465f5fd6
- Location:
- src/classes
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
re17861c
|
r80713b0
|
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | | public static function checkFreshness($date) |
| | 232 | /** |
| | 233 | * Generates appropriate headers, based on document age. |
| | 234 | * |
| | 235 | * @param int $time timestamp with the last update of the document being generated |
| | 236 | */ |
| | 237 | public static function checkFreshness($time) |
| 233 | 238 | { |
| 234 | 239 | $since = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']); |
| 235 | 240 | |
| 236 | | if( $since && $since > strtotime($date) ) |
| | 241 | if( $since && $since > $time ) |
| 237 | 242 | { |
| 238 | 243 | header('HTTP/1.1 304 Not Modified'); |
| … |
… |
|
| 241 | 246 | else |
| 242 | 247 | { |
| 243 | | header('Last-Modified: '.gmdate('D, d M Y H:i:s', $date).' GMT'); |
| 244 | | header('ETag: '.md5($date)); |
| | 248 | header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); |
| | 249 | header('ETag: '.md5($time)); |
| 245 | 250 | } |
| 246 | 251 | } |
-
|
r412005a
|
r80713b0
|
|
| 62 | 62 | $posts = PostsLogic::getBatch($page); |
| 63 | 63 | |
| 64 | | $this->view->checkFreshness($posts[0]->date); |
| | 64 | $this->view->checkFreshness(strtotime($posts[0]->date)); |
| 65 | 65 | |
| 66 | 66 | $this->view->assign('posts', $posts); |
| … |
… |
|
| 74 | 74 | |
| 75 | 75 | $posts = PostsLogic::getBatch($page, Logic::getConfig()->POSTS_PER_PAGE); |
| 76 | | $this->view->checkFreshness($posts[0]->date); |
| | 76 | $this->view->checkFreshness(strtotime($posts[0]->date)); |
| 77 | 77 | |
| 78 | 78 | $this->view->assign('posts', $posts); |
| … |
… |
|
| 83 | 83 | { |
| 84 | 84 | $posts = PostsLogic::getBatch(1, Logic::getConfig()->POSTS_PER_PAGE); |
| 85 | | $this->view->checkFreshness($posts[0]->date); |
| | 85 | $this->view->checkFreshness(strtotime($posts[0]->date)); |
| 86 | 86 | |
| 87 | 87 | $this->view->assign('posts', $posts); |
-
|
r412005a
|
r80713b0
|
|
| 49 | 49 | $posts = PostsLogic::getBatchByUser($page, $userId); |
| 50 | 50 | |
| 51 | | $this->view->checkFreshness($posts[0]->date); |
| | 51 | $this->view->checkFreshness(strtotime($posts[0]->date)); |
| 52 | 52 | |
| 53 | 53 | $this->view->assign('posts', $posts); |
| … |
… |
|
| 88 | 88 | $posts = PostsLogic::getBatchByUser($page, $_GET['userId']); |
| 89 | 89 | |
| 90 | | $this->view->checkFreshness($posts[0]->date); |
| | 90 | $this->view->checkFreshness(strtotime($posts[0]->date)); |
| 91 | 91 | |
| 92 | 92 | $this->view->assign('posts', $posts); |