Fetch images automatically

On this page

Sirv can automatically fetch images from your server by HTTP, HTTPS or S3.

Whenever an image is requested from your Sirv account, or it is missing, it will attempt to fetch it from your server or S3 bucket. Once fetched, Sirv stores the original image in your Sirv account.

HTTP/HTTPS fetching

Sirv can fetch images from a particular folder on your server by HTTP or HTTPS.

Let's assume your source images are located in this folder of your website:

https://your-domain.com/my-images/

Now let's say you want to serve this image from Sirv:

https://your-domain.com/my-images/example-folder/an-image.jpg

You can request that file from your Sirv account, like so:

https://your-account.sirv.com/example-folder/an-image.jpg

If it doesn't already exist in your Sirv account, Sirv will fetch it from your server, then optimize and serve it. Fetching typically happens in less than 1 second, depending how quickly your server responds.

S3 fetching

Sirv can also fetch images from your Amazon S3 bucket or any non-Amazon S3 bucket.

Either the whole bucket or a specific folder can be fetched from.

You can use either virtual hosted-style or path-style URLs to access your S3 bucket:

  • Virtual hosted-style: https://<bucket>.<s3_server>/object
  • Path-style: https://<s3_server>/<bucket>/object

Enable fetching

To enable fetching, go to your Settings page in your Sirv account and click "Set up Auto-Fetch":

Configure image fetching from S3 or HTTPS

Either configure HTTP fetching by entering your remote server URL, folder (optional) and username/password (if your domain uses authentication):

Configure HTTP image fetching

Or configure S3 fetching by entering the Amazon AWS S3 or other S3 bucket. Also enter your access key ID, secret access key and folder path (optional):

Configure S3 image fetching

File fetching is available to all paid Sirv plans. If you have a Trial or Free plan, switch to a paid plan to start using fetching immediately.

Image processing

All the usual image processing options can be applied to the image. For example:

https://your-account.sirv.com/example-folder/image.jpg?w=500&profile=xyz

Sirv will fetch this image from your server:

https://your-domain.com/my-images/example-folder/image.jpg

... then serve it with these options ?w=500&profile=xyz.

Updating a changed image

If an image changes on your server, the old image will continue to be served by Sirv until you delete it from your Sirv account. Once deleted, Sirv will refetch the image the next time it is requested.

Rate limit

Up to 1000 fetch requests can be sent per hour (2000 per hour for Enterprise accounts). If your account exceeds that, a 429 error (rate exceeded) will be served until the limit is reset (within 1 hour). If you need a larger limit, please contact us.

File size limit

The maximum file size Sirv will fetch via S3 is 300MB.

The maximum file size Sirv will fetch via HTTP is:

Typical file Large file
Enterprise plan 7 MB, 2000 files per hour 32 MB, 10 files per hour
Business plan 4 MB, 1000 files per hour 32 MB, 10 files per hour
Trial plan 3 MB, 1000 files per hour 32 MB, 10 files per hour
Free plan None None

If you would like a higher limit, please submit a request explaining your requirements.

Troubleshooting

You will see a list of failed fetches in your Sirv account. You can investigate the errors to see if there is a genuine problem.

Possible causes of errors

Common causes of why files are not fetched:

  • 403 error - your server refused Sirv access to the file. There are many possible reasons, such as forbidden access, rejected IP address or invalid configuration.
  • 404 error - the file is missing from your server. Resolve this by checking the Referrer field, to see which web page is referencing the file, then either fix the broken URL or upload the missing image to your server.
  • 504 error - your server terminated the request as a timeout, after some time. Check if your server is using rate limiting. If so, either increase or remove the rate limit for Sirv IP addresses.
  • Timeout was reached - Sirv timed out the request after 10 seconds and returned a 504 response because your server either didn't respond or didn't finish responding. Your server may have a firewall or proxy that is rate-limiting or blocking requests from Sirv IPs, particularly if many requests were sent in a short space of time. If your firewall/proxy is delaying/blocking the Sirv user agent Sirv Image Service, add a firewall rule to allow requests from Sirv's user agent.
  • SSL peer certificate or SSH remote key was not OK - the domain of the remote server does not have a valid SSL certificate. Configure an SSL certificate on your domain or fetch over HTTP instead of HTTPS. Sirv will return a 526 error response.
  • Number of redirects hit maximum amount - the remote domain did not return the image - it redirected Sirv's request to another location. One redirect is permitted; a second redirect will fail. Sirv will return a 500 error response.

Automatic retry

If a file fails to be fetched from your server, Sirv will allow that same URL to be retried after a 1 minute delay, followed by further attempts at increasing intervals (known as exponential backoff). Look for the retryAfter value in the response, to know what time the next attempt will be permitted. The retryAfter time can also be seen in a ?info request - see below.

Additional troubleshooting information

To help you investigate deeper, each fetch attempt can be seen by appending ?info to the file URL, for example:

https://test-account.sirv.com/no-image-here.jpg?info

You will see a list of fetching attempts with date, time, error name and message e.g.

Fetch images automatically - screenshot of JSON information when 406 error

The date and time is shown in ISO 8601 date format e.g. 2021-07-08T00:54:57.814Z, where Z denotes UTC time.

Failure notifications

Failed fetches are displayed as notifications on your Events page. Notifications contain the source URL, referrer, status code and error code:

Fetch images automatically - error notifications

Service information

If you require a list of Sirv servers (IP addresses) used for fetching, send us a request via your account.

The HTTP Referrer header field used by the Sirv agent is:

Sirv Image Service

Create your Sirv account

If you don't have a Sirv account yet, create your account today.

Was this article helpful?

Get help from a Sirv expert

help ukraine help ukraine Powered by Ukrainian determination and British ingenuity

How can you support Ukraine