Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[huntr] adding cache control headers to the admin area (#3097)
This PR forces the `Cache-Control: no-store, max-age=0` header to the response in the Admin Area. This forces cache to be ignored upon browsing back and forth between pages using the browser controls. Although absolutely no fail safe, it should provide better protection against serving cached pages once an admin has signed out.
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Admin\Middleware; | ||
|
||
use Psr\Http\Message\ResponseInterface as Response; | ||
use Psr\Http\Message\ServerRequestInterface as Request; | ||
use Psr\Http\Server\MiddlewareInterface as Middleware; | ||
use Psr\Http\Server\RequestHandlerInterface as Handler; | ||
|
||
class DisableBrowserCache implements Middleware | ||
{ | ||
public function process(Request $request, Handler $handler): Response | ||
{ | ||
$response = $handler->handle($request); | ||
|
||
return $response->withHeader('Cache-Control', 'max-age=0, no-store'); | ||
} | ||
} |