diff --git a/config/queue-it.php b/config/queue-it.php index 0f0fe2c..77bf28a 100644 --- a/config/queue-it.php +++ b/config/queue-it.php @@ -12,4 +12,11 @@ 'config_update_url' => env('QUEUE_IT_CONFIG_UPDATE_URL', '/queue-it/config'), + 'redirect_cache_headers' => [ + 'no_store' => true, + 'no_cache' => true, + 'must_revalidate' => true, + 'max_age' => 0, + ], + ]; diff --git a/src/Http/Middleware/InlineQueue.php b/src/Http/Middleware/InlineQueue.php index 626fdb1..d051140 100644 --- a/src/Http/Middleware/InlineQueue.php +++ b/src/Http/Middleware/InlineQueue.php @@ -56,11 +56,13 @@ public function __construct( */ public function handle(Request $request, Closure $next, ...$eventConfigParams) { + $customerId = config('queue-it.customer_id'); + $secretKey = config('queue-it.secret_key'); + $cacheHeaders = config('queue-it.redirect_cache_headers'); + $urlWithoutToken = $request->fullUrlWithoutQuery(self::TOKEN_KEY); $token = $request->query(self::TOKEN_KEY); $eventConfig = $this->getEventConfig(...$eventConfigParams); - $customerId = config('queue-it.customer_id'); - $secretKey = config('queue-it.secret_key'); $result = KnownUser::resolveQueueRequestByLocalConfig( $urlWithoutToken, @@ -71,10 +73,7 @@ public function handle(Request $request, Closure $next, ...$eventConfigParams) ); if ($result->doRedirect()) { - return redirect($result->redirectUrl)->withHeaders([ - 'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0', - 'Pragma' => 'no-cache', - ]); + return redirect($result->redirectUrl)->setCache($cacheHeaders); } if ($result->actionType === ActionTypes::QueueAction && $request->filled(self::TOKEN_KEY)) { diff --git a/src/Http/Middleware/KnownUserQueue.php b/src/Http/Middleware/KnownUserQueue.php index 754f622..6de3f13 100644 --- a/src/Http/Middleware/KnownUserQueue.php +++ b/src/Http/Middleware/KnownUserQueue.php @@ -24,6 +24,7 @@ public function handle(Request $request, Closure $next) { $customerId = config('queue-it.customer_id'); $secretKey = config('queue-it.secret_key'); + $cacheHeaders = config('queue-it.redirect_cache_headers'); $token = $request->query(self::TOKEN_KEY); $urlWithoutToken = $request->fullUrlWithoutQuery(self::TOKEN_KEY); @@ -40,10 +41,7 @@ public function handle(Request $request, Closure $next) ); if ($result->doRedirect()) { - return redirect($result->redirectUrl)->withHeaders([ - 'Cache-Control' => 'no-store, no-cache, must-revalidate, max-age=0', - 'Pragma' => 'no-cache', - ]); + return redirect($result->redirectUrl)->setCache($cacheHeaders); } if ($result->actionType === ActionTypes::QueueAction && $request->filled(self::TOKEN_KEY)) {