mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-02-01 19:59:13 +00:00
593645acfe
Allows files to be placed within a "public" folder within a theme directory which the contents of will served by BookStack for access. - Only "web safe" content-types are provided. - A static 1 day cache time it set on served files. For #3904
42 lines
1,000 B
PHP
42 lines
1,000 B
PHP
<?php
|
|
|
|
namespace BookStack\Http\Middleware;
|
|
|
|
use Closure;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class PreventResponseCaching
|
|
{
|
|
/**
|
|
* Paths to ignore when preventing response caching.
|
|
*/
|
|
protected array $ignoredPathPrefixes = [
|
|
'theme/',
|
|
];
|
|
|
|
/**
|
|
* 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);
|
|
|
|
$path = $request->path();
|
|
foreach ($this->ignoredPathPrefixes as $ignoredPath) {
|
|
if (str_starts_with($path, $ignoredPath)) {
|
|
return $response;
|
|
}
|
|
}
|
|
|
|
$response->headers->set('Cache-Control', 'no-cache, no-store, private');
|
|
$response->headers->set('Expires', 'Sun, 12 Jul 2015 19:01:00 GMT');
|
|
|
|
return $response;
|
|
}
|
|
}
|