Some of you may have a solution for this, and I need to hear it. Basically, you have a website, a lot of categories ( games, blog etc ).

The idea would be to use Amazon CDN for images, flv's, javascript js, and css. What's the best way to implement Amazon CloudFront to make this work?

Would I sync only the images etc, keeping the structure intact? I've been using

RewriteEngine On
RewriteCond %{REQUEST_URI} .*jpg$|.*gif$|.*png$ [NC]
RewriteRule (.*) http://www.google.com/$1 [R]

in order to server images, but also keeping the relative paths. So


would redirect to


The idea is to make no changes to the website. I'm not sure if to not kick s3fs directly to the image directories, and have everything upload to the respective mount points ( is the speed fast enough ? )

  • Why are you considering implementing CloudFront? What are you trying to achieve here? – WheresAlice Jun 22 '10 at 20:34
  • This is related to alot of SEO stuff, ranking etc. – Adrian A. Jun 23 '10 at 16:37

Not really the best use of a CDN.. the idea is to take requests away from your webserver.. All that will do is remove the bandwidth.

Its better to change the code itself to take the request for the images out of the webserver.

  • 1
    If that were possible, I wouldn't be asking for ideas on alternative solutions :) – Adrian A. Jun 23 '10 at 16:36

You could use some output buffering and cache to process all links and change them to the CF CNAME before being sent to the client. Then set-up a custom origin CF pointing to your standard domain.

This will require no other changes and will route all traffic for static content to CF but actually leaving the original content on the same server as is.

The above could also be achieved client-side with some DOM manipulation using Javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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