Skip to content

Commit f304ba7

Browse files
(v2.1) add cache headers
1 parent b4b05a8 commit f304ba7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Controllers/LaravelRequestDocsController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ public function api(Request $request)
5555
);
5656
}
5757

58-
5958
return response()->json(
6059
$docs,
6160
Response::HTTP_OK,
6261
[
63-
'Content-type'=> 'application/json; charset=utf-8'
62+
'Content-type'=> 'application/json; charset=utf-8',
63+
'Cache-Control' => 'public, max-age=60',
64+
'Expires' => gmdate('D, d M Y H:i:s \G\M\T', time() + 60),
6465
],
6566
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
6667
);
@@ -95,8 +96,8 @@ public function assets(Request $request)
9596
}
9697

9798
// set cache control headers
98-
$headers['Cache-Control'] = 'public, max-age=31536000';
99-
$headers['Expires'] = gmdate('D, d M Y H:i:s \G\M\T', time() + 31536000);
99+
$headers['Cache-Control'] = 'public, max-age=1800';
100+
$headers['Expires'] = gmdate('D, d M Y H:i:s \G\M\T', time() + 1800);
100101
return response()->file($path, $headers);
101102
}
102103
return response()->json(['error' => 'file not found'], 404);

0 commit comments

Comments
 (0)