我的Laravel应用程序默认 for each 站点返回Cache-Control: no-cache, private
个HTTP头.我怎样才能改变这种行为?
附言:它不是PHP.ini问题,因为将session.cache_limiter
更改为空/公共不会改变任何东西.
我的Laravel应用程序默认 for each 站点返回Cache-Control: no-cache, private
个HTTP头.我怎样才能改变这种行为?
附言:它不是PHP.ini问题,因为将session.cache_limiter
更改为空/公共不会改变任何东西.
你可以有一个全球性的中间件.比如:
<?php
namespace App\Http\Middleware;
use Closure;
class CacheControl
{
public function handle($request, Closure $next)
{
$response = $next($request);
$response->header('Cache-Control', 'no-cache, must-revalidate');
// Or whatever you want it to be:
// $response->header('Cache-Control', 'max-age=100');
return $response;
}
}
然后在内核文件中将其注册为全局中间件:
protected $middleware = [
....
\App\Http\Middleware\CacheControl::class
];