-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticCache.php
More file actions
33 lines (24 loc) · 829 Bytes
/
StaticCache.php
File metadata and controls
33 lines (24 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
namespace Alps\CacheEvader\Http\Middleware;
use Closure;
use Illuminate\Contracts\Config\Repository;
class StaticCache extends \Statamic\StaticCaching\Middleware\Cache
{
public function handle($request, Closure $next)
{
/** @var Repository $config */
$config = resolve(Repository::class);
$paramNames = $config->get('statamic.cache-evader.evade_http_parameter_names');
if (! $request->hasAny($paramNames)) {
return parent::handle($request, $next);
}
$privateNext = function ($request) use ($next) {
$response = $next($request);
$response->headers->add([
'X-Statamic-Private' => 'true',
]);
return $response;
};
return parent::handle($request, $privateNext);
}
}