diff --git a/config/install/s3fs.settings.yml b/config/install/s3fs.settings.yml
index 36561c5..9b54a9d 100644
--- a/config/install/s3fs.settings.yml
+++ b/config/install/s3fs.settings.yml
@@ -19,3 +19,4 @@ private_folder: ''
 presigned_urls: ''
 saveas: ''
 torrents: ''
+redirect_ttl: '86400'
\ No newline at end of file
diff --git a/src/Controller/S3fsImageStyleDownloadController.php b/src/Controller/S3fsImageStyleDownloadController.php
index 4c35165..b7ff736 100644
--- a/src/Controller/S3fsImageStyleDownloadController.php
+++ b/src/Controller/S3fsImageStyleDownloadController.php
@@ -100,28 +100,42 @@ class S3fsImageStyleDownloadController extends ImageStyleDownloadController {
         // Tell client to retry again in 3 seconds. Currently no browsers are
         // known to support Retry-After.
         throw new ServiceUnavailableHttpException(3, $this->t('Image generation in progress. Try again shortly.'));
+
       }
     }
 
     // Try to generate the image, unless another thread just did it while we were
     // acquiring the lock.
+    var_dump($derivative_uri);
     $success = file_exists($derivative_uri);
-
     if (!$success) {
     // If we successfully generate the derivative, wait until S3 acknowledges
     // its existence. Otherwise, redirecting to it may cause a 403 error.
-    $success = $image_style->createDerivative($image_uri, $derivative_uri) &&
-      \Drupal::service('stream_wrapper_manager')->getViaScheme('s3')->waitUntilFileExists($derivative_uri);
+      $created = $image_style->createDerivative($image_uri, $derivative_uri);
+      var_dump('created');
+      var_dump($created);
+      $success = $image_style->createDerivative($image_uri, $derivative_uri) &&
+        \Drupal::service('stream_wrapper_manager')->getViaScheme('s3')->waitUntilFileExists($derivative_uri);
+      var_dump('CREATE');
+      var_dump($success);
     }
+//    var_dump($derivative_uri);
+//    var_dump($image_uri);
+//    var_dump($success);
 
     if (!empty($lock_acquired)) {
       $this->lock->release($lock_name);
     }
-
+    //die('gedoan');
     if ($success) {
       // Perform a 302 Redirect to the new image derivative in S3.
       // It must be TrustedRedirectResponse for external redirects.
-      return new TrustedRedirectResponse(file_create_url($derivative_uri));
+      $response =  new TrustedRedirectResponse(file_create_url($derivative_uri));
+      // Cache the output of this response.
+      $ttl = $config = \Drupal::config('s3fs.settings')->get('redirect_ttl');
+      $response
+        ->addCacheableDependency((new \Drupal\Core\Cache\CacheableMetadata())->setCacheMaxAge($ttl));
+      return $response;
     }
     else {
       $this->logger->notice('Unable to generate the derived image located at %path.', ['%path' => $derivative_uri]);
diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php
index f14d091..f0788e1 100644
--- a/src/Form/SettingsForm.php
+++ b/src/Form/SettingsForm.php
@@ -255,6 +255,7 @@ class SettingsForm extends ConfigFormBase {
       ],
     ];
 
+
     $php_storage = Settings::get('php_storage');
     $twig_storage = !empty($php_storage['twig']['directory'])
       ? $php_storage['twig']['directory']
@@ -288,6 +289,12 @@ class SettingsForm extends ConfigFormBase {
         <em>$settings[\'s3fs.use_s3_for_private\'] = TRUE;</em>'
       ),
     ];
+    $advanced['redirect_ttl'] = [
+      '#type' => 'textfield',
+      '#title' => $this->t('the ttl of the redirect to the s3 styles'),
+      '#default_value' => $config->get('redirect_ttl'),
+      '#description' => $this->t('Styles will be redirected to S3. This will be the ttl of these redirect responses.  = keep the redirect in cache for X seconds.'),
+    ];
     $advanced['root_folder'] = [
       '#type' => 'textfield',
       '#title' => $this->t('Root Folder'),
@@ -381,6 +388,7 @@ class SettingsForm extends ConfigFormBase {
         ]
       ),
     ];
+
     return parent::buildForm($form, $form_state);
   }
 
@@ -391,6 +399,7 @@ class SettingsForm extends ConfigFormBase {
     $values = $form_state->getValues();
     $this->config('s3fs.settings')
       ->set('access_key', $values['access_key'])
+      ->set('redirect_ttl', $values['redirect_ttl'])
       ->set('secret_key', $values['secret_key'])
       ->set('use_instance_profile', $values['use_instance_profile'])
       ->set('default_cache_config', $values['default_cache_config'])
