I have a (high-traffic) chunk of my website that is entirely static. All the site's URLs are relative, so right now it all works if I just point my browser to http://gj232j2j213.cloudfront.net/blah
.
I'd like to host the entire thing (not just images and css, but the HTML too) on Cloudfont (or some other CDN).
Ideally, I could put something like:
GET /static/ staticDir:http://gj232j2j213.cloudfront.net/blah
in my routes file. That way my URLs would look like www.mydomain.com/static/main.html
, and I wouldn't have to bounce the user to a different subdomain as they moved back and forth between my static and non-static URLs.
Any ideas? Am I misguided?
I've used the following in my conf/routes
file to do this:
# Map static resources from the /app/public folder to the /public path
#{if play.Play.mode.isDev()}
GET /public/ staticDir:public
#{/}
#{else}
GET d2iu8jbjgczc8x.cloudfront.net/public staticDir:public
GET /public/ staticDir:public
#{/}
Then you just reference the static assets the normal way and the URLs will use the CloudFront server (in Prod mode).