Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8194875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:57:29+00:00 2026-06-07T04:57:29+00:00

In development mode I would like to have assets served locally and when deployed

  • 0

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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:57:31+00:00Added an answer on June 7, 2026 at 4:57 am

    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

    @(path: String)@Html((""""%s%s?v=%s"""").format(
    play.api.Play.current.configuration.getString("application.cdn").get,
    routes.Assets.at(path), 
    play.api.Play.current.configuration.getString("application.version").get ))
    

    USE

    @_asset(“stylesheets/css.min.css”)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app runs fine in development mode. When I run in production mode using
I have a GWT application which I would like to run from within a
I have a rails application, running in development mode ( with a sqlite database
I am a newbie to Android and the Eclipse development environment and would like
I would like to reload production application running with Thin. I know there is
I would like to know what yours Hadoop development environment looks like? Do you
I have a project which would like to utilize the Google Guava libraries (on
I would like to know how can I force a model loading in development
I am beginning Android app development and I would like to know which device
Can someone suggest a simple git branching mode for website development. I have seen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.