Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I never used a CDN before so this is a noob question, but how does it work on the tech side.

For example right now when a user uploads an image on my site it is uploaded to the "/uploads" folder at the root of my "www" folder via PHP. If I use Amazon S3, how will I make the images my users upload, go directly to Amazon's servers instead of mine?

Or does it work a different way like the images are still uploaded to my server but then I have to move them to the amazon server either manually or through a CRON job? Basically can someone explain to me how it works?

share|improve this question

migrated from stackoverflow.com Feb 2 '12 at 3:33

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

up vote 3 down vote accepted

A common way that CDN services work is whats known as origin based. What this means is you can have a secret. folder were all the content you want the cdn to be looking for is help. You allow users to upload to this folder normally and when in your code you give a URL like. cdn.example.com/images/my.png the cdn service will look at your site and download a copy of my.png then save a cache a copy on there network. Now all loads after this will load from the cdn. After sometime the cdn may come back and check to make sure that the image is still the same image. But once the cdn's network has the file they are able to share it with there servers world wide making your site faster.

share|improve this answer
    
I prefer this over what I thought was the only way, where you send all uploads directly to amazon. That seems efficient but I like the safety of having a copy on my server as backup in case amazon ever drops me as a customer and doesn't give my files back. –  JakeRow123 Jan 25 '12 at 16:31
    
There are cdn's that you do need to upload just double check the service you are signing up for send an email to there support staff but for the cdn's i have used and the one i made a joke thats how they all worked. –  WojonsTech Jan 25 '12 at 16:33
add comment

Or does it work a different way like the images are still uploaded to my server but then I have to move them to the amazon server either manually or through a CRON job? Basically can someone explain to me how it works?

Amazon's CloudFront supports "origin-pull" (via "custom origin"), where you tell it to look at your site for the files if it doesn't have a copy stored already. This prevents you from having to do any mirroring to S3.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.