|
7 | 7 | use Illuminate\Contracts\Debug\ExceptionHandler; |
8 | 8 | use Illuminate\Contracts\Http\Kernel; |
9 | 9 | use Illuminate\Http\Request; |
| 10 | +use Illuminate\Http\Response; |
10 | 11 | use Illuminate\Support\Collection; |
11 | 12 | use Illuminate\Support\Facades\Blade; |
12 | 13 | use Illuminate\Support\Facades\Event; |
|
33 | 34 | use Rapidez\Core\Http\Middleware\CheckStoreCode; |
34 | 35 | use Rapidez\Core\Http\Middleware\ConfigForTesting; |
35 | 36 | use Rapidez\Core\Http\Middleware\DetermineAndSetShop; |
| 37 | +use Rapidez\Core\Http\Middleware\Uncacheable; |
36 | 38 | use Rapidez\Core\Listeners\Healthcheck\ElasticsearchHealthcheck; |
37 | 39 | use Rapidez\Core\Listeners\Healthcheck\MagentoSettingsHealthcheck; |
38 | 40 | use Rapidez\Core\Listeners\Healthcheck\ModelsHealthcheck; |
|
42 | 44 | use Rapidez\Core\ViewComponents\PlaceholderComponent; |
43 | 45 | use Rapidez\Core\ViewDirectives\WidgetDirective; |
44 | 46 | use Symfony\Component\HttpKernel\Exception\HttpException; |
| 47 | +use TorMorten\Eventy\Facades\Eventy; |
45 | 48 |
|
46 | 49 | class RapidezServiceProvider extends ServiceProvider |
47 | 50 | { |
@@ -69,7 +72,8 @@ public function boot() |
69 | 72 | ->bootScout() |
70 | 73 | ->bootTranslations() |
71 | 74 | ->bootListeners() |
72 | | - ->bootMacros(); |
| 75 | + ->bootMacros() |
| 76 | + ->bootUncacheable(); |
73 | 77 | } |
74 | 78 |
|
75 | 79 | public function register() |
@@ -230,6 +234,7 @@ protected function bootMiddleware(): self |
230 | 234 | $this->app->make(Kernel::class)->pushMiddleware(DetermineAndSetShop::class); |
231 | 235 |
|
232 | 236 | $this->app['router']->aliasMiddleware('store_code', CheckStoreCode::class); |
| 237 | + $this->app['router']->aliasMiddleware('uncacheable', Uncacheable::class); |
233 | 238 |
|
234 | 239 | return $this; |
235 | 240 | } |
@@ -299,6 +304,17 @@ function ($filename) use ($manifest) { |
299 | 304 | return $this; |
300 | 305 | } |
301 | 306 |
|
| 307 | + protected function bootUncacheable(): static |
| 308 | + { |
| 309 | + Eventy::addFilter('uncacheable.response', function (Response $response) { |
| 310 | + $response->setPrivate(); |
| 311 | + |
| 312 | + return $response; |
| 313 | + }); |
| 314 | + |
| 315 | + return $this; |
| 316 | + } |
| 317 | + |
302 | 318 | protected function registerConfigs(): self |
303 | 319 | { |
304 | 320 | $this->mergeConfigFrom(__DIR__ . '/../config/rapidez.php', 'rapidez'); |
|
0 commit comments