Take the 2-minute tour ×

Is there any possiblity to trigger a 302 instead of an 404 in cloudfont?

I am currently working on a CDN for pictures. The basic setup should be like that

1) Our server delivers a HTML page with pictures in it. Those pictures are linked to a cdn in amazons cloudfont

2) If the file, does not yet exists in the cloud font, the call should be redirected to a server, which has two jobs

2.1.1) Get the picture from a S3 storage, where all pictures are uploaded without resizing

2.1.2) Resize that image using timthumb

2.1.3) Upload this image to the S3 storage deployed in the cloudfont

2.2) deliver the image once, so that the picture will be displyed even though not yet present in cloud font

3) The next call will not be a 404, so does not trigger a redirect to the timthumb script, but delivered statically from the cloudfont

Everything is done so far, but the 302 trigger. So is there any possiblity to trigger a 302 but a 404 in cloudfont?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I don't think you can do this the way you want as CloudFront just sits in front of S3 or another server.

The choices I see you having are:

  1. Look at the S3 event notifications to see if there's one for uploads, then when a file gets uploaded, pull it onto another server for resizing and upload it back to S3

  2. When a file is uploaded use the notification to your own application - presume you're storing a reference to the file somewhere - as a a trigger to download the picture, resize it and re-uploading

  3. Store the pictures on your own server, with CloudFront infront, then when a size you don't have is requested, generate the required size an serve it out via CloudFront.

There are also probably hybrid options of the two approaches too.

share|improve this answer
usage of the notification system is actually a really good idea. Will try that some time. The current setup pulls from s3, if he does not find a resized image in its cache. This way I have to use a server as middleware, but it is working like a charm. –  MatthiasLaug Dec 31 '11 at 7:41
add comment

Your Answer


