I recently deployed my Node.js blog on AppFog. I plan to use a bucket on Amazon S3 to stream my assets (javascript/stylesheets/images).
How can I make sure that Express.js get static assets to my Amazon S3 bucket instead of the regular /public?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I wouldn’t stream assets through the node server – it’s a waste of resources, and you’re going to have to deal with HTTP caching headers.
Instead, your HTML should link directly to the S3 bucket. Instead of:
Do:
Given that you’re migrating, just set up a permanent redirect.
This will redirect all requests for things in the js, css, and images folders to a S3 bucket. For example, /js/script.js would redirect to //s3.amazonaws.com/bucket/js/script.js.
This will help ease the transition, but you should still migrate your site’s references to the S3 URLs to eliminate the unnecessary HTTP roundtrip cause by having the redirect.