File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,10 +38,19 @@ public function __invoke(Request $request)
3838 });
3939
4040 return Response::make ($ response ['body ' ], 200 , [
41+ 'Cache-Control ' => $ this ->edgeCacheControlHeader (),
4142 'Content-Type ' => $ response ['contentType ' ],
43+ 'Vary ' => 'Host ' ,
4244 ]);
4345 }
4446
47+ private function edgeCacheControlHeader (): string
48+ {
49+ $ ttl = (int ) Config::get ('pinkary.cache_ttl ' );
50+
51+ return "public, max-age= {$ ttl }, s-maxage= {$ ttl }" ;
52+ }
53+
4554 private function replacePinkaryDomainWithHostDomain (string $ body , Request $ request ): string
4655 {
4756 $ paths = [
Original file line number Diff line number Diff line change 4444 $ testResponse ->assertSee ('https://pinkary.com/@kapersoft ' );
4545 $ testResponse ->assertDontSee ('http://localhost/@kapersoft ' );
4646 $ testResponse ->assertHeader ('Content-Type ' , 'text/html; charset=UTF-8 ' );
47+ $ cacheControl = (string ) $ testResponse ->headers ->get ('Cache-Control ' );
48+ expect ($ cacheControl )->toContain ('public ' )
49+ ->and ($ cacheControl )->toContain ('max-age=3600 ' )
50+ ->and ($ cacheControl )->toContain ('s-maxage=3600 ' );
51+ $ testResponse ->assertHeader ('Vary ' , 'Host ' );
4752 assertSame ([
4853 'body ' => $ responseBody = <<<'HTML'
4954 <link rel="shortcut icon" href="http://localhost/img/ico.svg">
7277 $ testResponse ->assertStatus (200 );
7378 $ testResponse ->assertSee ('pinkary profile picture ' );
7479 $ testResponse ->assertHeader ('Content-Type ' , 'image/png ' );
80+ $ cacheControl = (string ) $ testResponse ->headers ->get ('Cache-Control ' );
81+ expect ($ cacheControl )->toContain ('public ' )
82+ ->and ($ cacheControl )->toContain ('max-age=3600 ' )
83+ ->and ($ cacheControl )->toContain ('s-maxage=3600 ' );
84+ $ testResponse ->assertHeader ('Vary ' , 'Host ' );
7585 assertSame ([
7686 'body ' => 'pinkary profile picture ' ,
7787 'contentType ' => 'image/png ' ,
You can’t perform that action at this time.
0 commit comments