|
|
@ -805,6 +805,9 @@ Class SiteController extends Controller { |
|
|
|
$msg = 'OK'; |
|
|
|
$msg = 'OK'; |
|
|
|
$meta = array(); |
|
|
|
$meta = array(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$httpStatus = 200; |
|
|
|
|
|
|
|
$customHeaders = array(); |
|
|
|
|
|
|
|
|
|
|
|
$videoId = $this->get('id', ''); |
|
|
|
$videoId = $this->get('id', ''); |
|
|
|
if (empty($videoId)) { |
|
|
|
if (empty($videoId)) { |
|
|
|
$code = 0; |
|
|
|
$code = 0; |
|
|
@ -816,13 +819,26 @@ Class SiteController extends Controller { |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
if (!empty($cachedData)) { |
|
|
|
if (!empty($cachedData)) { |
|
|
|
$meta = $cachedData; |
|
|
|
$meta = $cachedData; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//增加客户端缓存header |
|
|
|
|
|
|
|
$etag = md5(json_encode($meta)); |
|
|
|
|
|
|
|
$etag_from_client = !empty($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : ''; //get etag from client |
|
|
|
|
|
|
|
if (!empty($etag) && $etag == $etag_from_client) { |
|
|
|
|
|
|
|
$httpStatus = 304; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$meta_client_cache_seconds = FSC::$app['config']['meta_client_cache_seconds']; |
|
|
|
|
|
|
|
$customHeaders = array( |
|
|
|
|
|
|
|
"Cache-Control: max-age={$meta_client_cache_seconds}", |
|
|
|
|
|
|
|
"Etag: {$etag}", |
|
|
|
|
|
|
|
); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$code = 0; |
|
|
|
$code = 0; |
|
|
|
$msg = '此视频无缓存或缓存已过期'; |
|
|
|
$msg = '此视频无缓存或缓存已过期'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $this->renderJson(compact('code', 'msg', 'meta')); |
|
|
|
return $this->renderJson(compact('code', 'msg', 'meta'), $httpStatus, $customHeaders); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//保存视频meta数据到缓存,支持手动生成 |
|
|
|
//保存视频meta数据到缓存,支持手动生成 |
|
|
|