#laravel #http-headers #no-cache
Вопрос:
Я использую версию Laravel 7.4
Мне нужно добавить заголовок ко всему представлению.
Я создал ViewServiceProvider в пути AppProvidersViewServiceProvider и добавил в config/app.php
Вот мой код в функции загрузки
public function boot()
{
App::before(function($request)
{
Response::header('Cache-Control', 'nocache, no-store, max-age=0, s-maxage=0,must-revalidate');
Response::header('Pragma', 'no-cache');
Response::header('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT');
});
}
Я получаю эту ошибку
Приложение::до этого не найдено
Каков альтернативный способ добавления заголовков
Я также попробовал промежуточное программное обеспечение
public function handle(Request $request, Closure $next)
{
$response = $next($request);
$response->header('Cache-Control', 'nocache, no-store, max-age=0, s-maxage=0,must-revalidate');
$response->header('Pragma', 'no-cache');
$response->header('Expires', 'Fri, 01 Jan 1990 00:00:00 GMT');
return $response;
}
это также не добавляет в заголовки html.