Laravel - HTTP Response 처리
HTTP Request (요청) 헤더 설명
참고사이트 : https://www.lesstif.com/pages/viewpage.action?pageId=26083967
HTTP Response (응답) 헤더 설명
참고 사이트 : https://www.lesstif.com/pages/viewpage.action?pageId=26083972
route/web.php
use Illuminate\Http\Response;
Route::get('hello/world/{name}',function(){
$response = new Response('Hello World ' . $name, 200);
$response->header('Content-Type', 'text/plain');
return $response;
});
==라라벨 에서 간단하게==
Route::get('hello/world/{name}',function(){
return response('Hello World ' . $name, 200)->header('Content-Type','text/plain');
});
==다중헤더 설정==
Route::get('hello/world/{name}',function(){
return response('Hello World ' . $name, 200)
->header('Content-Type','text/plain')
->header('Cache-Control','max-age=' . 60*60 . ", must-revalidate");
//3600초동안 서버에 재요청하지않고 컨텐츠를 재사용 3600초 후 캐시 재검증
//보안이 중요한 로그인 등은 no-cache 설정하기
});