Fetch images automatically
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.
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:
Now let's say you want to serve this image from Sirv:
You can request that file from your Sirv account, like so:
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.
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
To enable fetching, go to your Settings page in your Sirv account and click "Set up Auto-Fetch":
Either configure HTTP fetching by entering your remote server URL, folder (optional) and username/password (if your domain uses authentication):
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):
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.
All the usual image processing options can be applied to the image. For example:
Sirv will fetch this image from your server:
... 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.
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|
If you would like a higher limit, please submit a request explaining your requirements.
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.
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. The second attempt is permitted after 2 minutes, then 4 minutes, 9 minutes, 16, 25, 36, 49 minutes etc. This technique is known as exponential backoff and it helps protect your account from hitting its hourly autofetch request limit due to a large volume of fetch requests for a file that cannot be fetched.
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 by visiting the file URL directly - see below.
Additional troubleshooting information
To help you investigate deeper, each fetch attempt can be seen by directly visiting the file URL in your browser, for example:
You will see a list of fetching attempts with date, time, error name and message e.g.
The date and time is shown in ISO 8601 date format e.g. 2021-07-08T00:54:57.814Z, where Z denotes UTC time.
Failed fetches are displayed as notifications on your Events page. Notifications contain the source URL, referrer, status code and error code:
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.