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: http://<bucket>.<s3_server>/object
- Path-style: http://<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 2000 fetch requests can be sent per hour (4000 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, 3000 files per hour||32 MB, 10 files per hour|
|Business plan||4 MB, 2000 files per hour||32 MB, 10 files per hour|
|Trial plan||3 MB, 2000 files per hour||32 MB, 10 files per hour|
If you would like a higher limit, please submit a request explaining your requirements.
If the requested image cannot be fetched from your server, Sirv will try to download it later, in accordance with the images' TTL. The minimum TTL is 15 minutes and increases with each new failed download attempt.
Failed fetches are displayed as notifications on your Events page. Notifications contain the source URL, status code and error code:
To help you investigate deeper, each attempted fetch is recorded in a JSON file containing the date, time and response code (error message) of each request. View the file by appending ?info to the image URL, for example:
You will see a "Fetching" section, which describes each fetching attempt. For example:
Possible causes of errors
- 403 error - your server refused access to a file. There are many possible reasons, such as forbidden read access, rejected IP address or invalid configuration.
- 404 error - the image is missing from your server. Resolve this by correcting the URL or uploading 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 (gave up) because your server didn't reply within 10 seconds. 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. Your server firewall/proxy may also be delaying/blocking the Sirv user agent Sirv Image Service. If so, please add a firewall rule to allow requests from the Sirv 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.
- 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.
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.