mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-13 05:53:55 +08:00
b90033a730
- Moves guest user caching from User class to app container for simplicity. - Updates test to use simpler $this->users->guest() method for consistency. - Streamlined helpers to avoid function overlap for simplicity. - Extracted user profile dropdown while doing changes.
32 lines
769 B
PHP
32 lines
769 B
PHP
<?php
|
|
|
|
namespace BookStack\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class PreventAuthenticatedResponseCaching
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
/** @var Response $response */
|
|
$response = $next($request);
|
|
|
|
if (!user()->isGuest()) {
|
|
$response->headers->set('Cache-Control', 'max-age=0, no-store, private');
|
|
$response->headers->set('Pragma', 'no-cache');
|
|
$response->headers->set('Expires', 'Sun, 12 Jul 2015 19:01:00 GMT');
|
|
}
|
|
|
|
return $response;
|
|
}
|
|
}
|