Giter VIP home page Giter VIP logo

play2-fastassets's Introduction

play2-fastassets

Accelerates Play2 development mode by leveraging browser cache.

At first, add the following dependency into your project/Build.scala:

resolvers += "amateras-repo" at "http://amateras.sourceforge.jp/mvn/"

libraryDependencies += "jp.sf.amateras.play2.fastassets" %% "play2-fastassets" % "0.0.4"

Replace the routing to controllers.Assets.at by jp.sf.amateras.play2.fastassets.FastAssets.get in conf/routes. This method returns a response which has a header: Cache-Control: private, max-age=3600.

#GET /assets/*file controllers.Assets.at(path="/public", file)
GET /assets/*file jp.sf.amateras.play2.fastassets.FastAssets.get(file)

And add following configurations into conf/application.conf.

fastassets.urlPath=/assets
fastassets.realPath=/public
fastassets.versioning=true

Use FastAssets.at instead of routes.Assets.at in HTML templates. This method appends a last modified timestamp to the filename and your browser cache it. When you update the file, this timestamp is also updated. So the browser retrieves a new file from the server instead of the cached contents.

@(title: String)(content: Html)
@import jp.sf.amateras.play2.fastassets.FastAssets
<!DOCTYPE html>
<html>
  <head>
    <title>@title</title>
    <link rel="stylesheet" media="screen" href="@FastAssets.at("stylesheets/main.css")">
    <link rel="shortcut icon" type="image/png" href="@FastAssets.at("images/favicon.png")">
    <script src="@FastAssets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
  </head>
  <body>
    @content
  </body>
</html>

Release Notes

0.1.0 - 3 Aug 2014

  • Update for Play 2.3 / Scala 2.11

0.0.4 - 24 Apr 2014

  • Add fastassets.versioning configuration to enable asset versioning in production.

0.0.3 - 16 Apr 2014

  • Update for play-2.2.2.

0.0.2 - 05 Jan 2014

  • Ignore Exception in FastAssets#at() for testing.

0.0.1 - 25 Feb 2013

  • This is an initial release of play2-fastassets. This version works for play-2.0.1.

play2-fastassets's People

Contributors

takezoe avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.