-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCDNCacheHelper.php
More file actions
31 lines (29 loc) · 861 Bytes
/
CDNCacheHelper.php
File metadata and controls
31 lines (29 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
* CDNCache Helper
*
* @author Noriko Arai <arai@nii.ac.jp>
* @author Kazunori Sakamoto <exkazuu@willbooster.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
* @copyright Copyright 2020, NetCommons Project
*/
/**
* CDNCache Helper
*
*/
class CDNCacheHelper extends AppHelper {
/**
* Return a boolean value whether the page is cacheable or not.
*
* @return bool a boolean value whether the page is cacheable or not.
*/
public function isCacheable() {
$nonOrigin = strncmp('origin-', $_SERVER['HTTP_HOST'], 7) !== 0 &&
strncmp('origin.', $_SERVER['HTTP_HOST'], 7) !== 0;
$nonCacheable = (isset($this->_View->response->header()['Pragma']) &&
$this->_View->response->header()['Pragma'] === 'no-cache') ||
$nonOrigin;
return !$nonCacheable;
}
}