docs: def s3_connection(self):
          """
          Connect to the Amazon S3 API.
  
          If the connection attempt fails because Boto can't find credentials the
          attempt is retried once with an anonymous connection.
  
          Called on demand by :attr:`s3_bucket`.
  
          :returns: A :class:`boto.s3.connection.S3Connection` object.
          :raises: :exc:`.CacheBackendError` when the connection to the Amazon
                   S3 API fails.
          """
          if not hasattr(self, 'cached_connection'):
              self.check_prerequisites()
              with PatchedBotoConfig():
                  import boto
                  from boto.exception import BotoClientError, BotoServerError, NoAuthHandlerFound
                  from boto.s3.connection import S3Connection, SubdomainCallingFormat, OrdinaryCallingFormat
                  try:
                      # Configure the number of retries and the socket timeout used
                      # by Boto. Based on the snippet given in the following email:
                      # https://groups.google.com/d/msg/boto-users/0osmP0cUl5Y/X4NdlMGWKiEJ
                      if not boto.config.has_section(BOTO_CONFIG_SECTION):
                          boto.config.add_section(BOTO_CONFIG_SECTION)
                      boto.config.set(BOTO_CONFIG_SECTION,
                                      BOTO_CONFIG_NUM_RETRIES_OPTION,
                                      str(self.config.s3_cache_retries))
                      boto.config.set(BOTO_CONFIG_SECTION,
                                      BOTO_CONFIG_SOCKET_TIMEOUT_OPTION,
                                      str(self.config.s3_cache_timeout))
                      logger.debug("Connecting to Amazon S3 API ..")
                      endpoint = urlparse(self.config.s3_cache_url)
                      host, _, port = endpoint.netloc.partition(':')
                      kw = dict(
                          host=host,
                          port=int(port) if port else None,
                          is_secure=(endpoint.scheme == 'https'),
                          calling_format=(SubdomainCallingFormat() if host == S3Connection.DefaultHost
                                          else OrdinaryCallingFormat()),
                      )
                      try:
                          self.cached_connection = S3Connection(**kw)
                      except NoAuthHandlerFound:
                          logger.debug("Amazon S3 API credentials missing, retrying with anonymous connection ..")
                          self.cached_connection = S3Connection(anon=True, **kw)
                  except (BotoClientError, BotoServerError):
                      raise CacheBackendError("""
                          Failed to connect to the Amazon S3 API! Most likely your
                          credentials are not correctly configured. The Amazon S3
                          cache backend will be disabled for now.
                      """)
          return self.cached_connection