In development mode I would like to have assets served locally and when deployed in production I would like them served from the CDN. Anyone using play2 and serving content from CDN be willing to share how they are doing it?
// Thinking of something like this in the routes file...
@if(play.Play.isDev()) {
GET /assets/*file controllers.Assets.at(path="/public", file)
} else {
GET CDNPATH/assets/*file controllers.Assets.at(path="CDNPATH", file)
}
(Note: using 2.0.2 because of the headers fix https://github.com/playframework/Play20/pull/276)
For those searching to do something similar, I found this link where someone describes exactly how to serve content from cdn using play:
http://www.jamesward.com/2012/08/08/edge-caching-with-play2-heroku-cloudfront
Here is another option, a function that I ended up using so that i could have my local system have application.cdn=”” and on production it has the real value. Also allows version change to invalidate cache:
_assets.scala.html
USE
@_asset(“stylesheets/css.min.css”)