benny_1
September 20, 2016, 8:56am
1
when getting a m3u8 manifest using this URL:
http://domain.com/p/101/sp/10100/playManifest/entryId/0_fdgfilop/format/applehttp/protocol/http/master.m3u8
the cache-control header is:
Cache-Control: private, max-age=60, max-stale=0
where can I change that?
jess
September 20, 2016, 11:19am
2
Hello,
The default value is set here:
*/
class KalturaResponseCacher extends kApiCache
{
// copied from KalturaResponseType
const RESPONSE_TYPE_XML = 2;
const RESPONSE_TYPE_PHP = 3;
static protected $cachedContentHeaders = array('content-type', 'content-disposition', 'content-length', 'content-transfer-encoding');
protected $_defaultExpiry = 0;
protected $_cacheHeadersExpiry = 60; // cache headers for CDN & browser - used for GET request with kalsig param
public function __construct($params = null, $cacheType = kCacheManager::CACHE_TYPE_API_V3, $expiry = 0)
{
if ($expiry)
$this->_defaultExpiry = $this->_expiry = $expiry;
$this->_cacheKeyPrefix = 'cache_v3-';
parent::__construct($cacheType, $params);
}
Then, in
$partnerId = $this->_ksObj ? $this->_ksObj->partner_id : 0;
$forceCachingHeaders = false;
if ($this->_ksObj && kConf::hasParam("force_caching_headers") && in_array($partnerId, kConf::get("force_caching_headers")))
$forceCachingHeaders = true;
// for GET requests with kalsig (signature of call params) return cdn/browser caching headers
if ($usingCache && $isAnonymous && $_SERVER["REQUEST_METHOD"] == "GET" && isset($_REQUEST["kalsig"]) &&
(!self::hasExtraFields() || $forceCachingHeaders))
{
$v3cacheHeadersExpiry = kConf::get('v3cache_headers_expiry', 'local', array());
if(isset($v3cacheHeadersExpiry[$partnerId]))
$this->_cacheHeadersExpiry = $v3cacheHeadersExpiry[$partnerId];
$max_age = !is_null($this->minCacheTTL) ? min($this->_cacheHeadersExpiry, $this->minCacheTTL) : $this->_cacheHeadersExpiry ;
header('Cache-Control: private, max-age=' . $max_age . ', max-stale=0');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $max_age) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastModified) . ' GMT');
}
else
{
there is an attempt to read an alternative value from app/configurations/local.ini.
The value is controlled per partner ID so in local.ini, assuming youtr partner ID is 101, you can add:
[v3cache_headers_expiry]
101 = 300
After reloading the Apache, the change should take affect and the value will be 300 instead of 60.
benny_1
September 20, 2016, 12:20pm
4
By the way,
Is it possible to have different cache responses for different http status codes?
Maybe different cache response for 404 erros than to 302,200 codes?
jess
September 21, 2016, 1:05pm
5
Hi @benny_1 ,
Sorry but I’m afraid that’s not supported in the current code.