Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Cloudfront module for play 2

Cloudfront enables to set up a CDN easily. This module helps to integrate your Cloudfront CDN with play.

Setting up with sbt

Configure a new resolver:

resolvers += "Mariot Chauvin repository" at ""

Add the library dependency:

libraryDependencies += "mchv" %% "play2-cloudfront" % "1.1"

Use a custom controller

Create a new file named RemoteAssets.scala that contains:

package controllers

import controllers._

object RemoteAssets extends Remote {
    def call(file:String) = {

Update the router file with the call to your custom controller for your assets:

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file     "/public", file)

Update your views to refer to your controller to fetch the url:

@(title: String)(content: Html)

<!DOCTYPE html>

        <link rel="stylesheet" media="screen" href="@RemoteAssets.url("stylesheets/main.css")">
        <link rel="shortcut icon" type="image/png" href="@RemoteAssets.url("images/favicon.png")">
        <script src="@RemoteAssets.url("javascripts/jquery-1.9.1.min.js")" type="text/javascript"></script>

Configure the module with your cloudfront settings

Add your Cloudfront url to the application.conf:



The module is based on James Ward tutorial If you want to know more or avoid the dependency, please read it.

You can’t perform that action at this time.