add last-modified header for json profiles

This commit is contained in:
printempw 2016-10-30 11:56:59 +08:00
parent 0df49ff670
commit 167c40f550

View File

@ -41,6 +41,13 @@ class ResponseMacroServiceProvider extends ServiceProvider
});
Response::macro('rawJson', function ($src = "", $status = 200, $header = []) {
$last_modified = Arr::get($header, 'Last-Modified', time());
if (strtotime(Arr::get($_SERVER, 'If-Modified-Since')) >= $last_modified) {
$status = 304;
$src = "";
}
return Response::make($src, $status, array_merge([
'Content-type' => 'application/json',
'Cache-Control' => 'public, max-age='.option('cache_expire_time') // 365 days