How to override Cache-Control header? #43460
Unanswered
siarheipashkevich
asked this question in
Q&A
Replies: 2 comments 4 replies
-
You can create a new middleware and then apply it inside <?php
// app/Http/Middleware/CacheControlMiddleware.php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class CacheControlMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
*/
public function handle(Request $request, Closure $next)
{
$response = $next($request);
$response->headers->set('Cache-Control', 'no-store');
return $response;
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
-
I think the right way here is to use built-in middleware - |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
Laravel application returns
Cache-Control: no-cache, private;
header by default.How I can override this and return just
no-store
?Best regards,
Sergey
Beta Was this translation helpful? Give feedback.
All reactions