First, I want to thank James Ward for this code which I largely used for this module. Specifically, this implementation is inspired by this blog: http://www.jamesward.com/2012/08/08/edge-caching-with-play2-heroku-cloudfront
With this 'module' you can get CDNs working easy.
-
Add the dependency on this module.
-
Add a value to your conf/application.conf file that points to your cdn.
cdn.contenturl="XXXXXXXXXXXXXX.cloudfront.net
By default the cdn assets will use HTTPS. If you don't want to use HTTPS, add this setting cdn.secure=false.
- Replace your Assets route in your conf/routes file like this.
If you had:
GET /assets/*file controllers.Assets.at(path="/public", file)
You now need
GET /assets/*file controllers.MyAssets.at(path=controllers.MyAssets.defaultPath, file)
- Replace all "routes.Assets.at" with "RemoteAssets.at" in your project. (note, you no longer need the "routes." because you are no longer using the reverse router.)