/play-assets-improvements

This demos how you can modify the Asset controller to use a CDN, Fingerprinting, and other modifications to the basic assets pipeline.

Primary LanguageScala

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.

  1. Add the dependency on this module.

  2. 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.

  1. 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)
  1. 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.)