object Assets

Controller that serves static resources.

Resources are searched in the classpath.

It handles Last-Modified and ETag header automatically. If a gzipped version of a resource is found (Same resource name with the .gz suffix), it is served instead. If a digest file is available for a given asset then its contents are read and used to supply a digest value. This value will be used for serving up ETag values and for the purposes of reverse routing. For example given "a.js", if there is an "a.js.md5" file available then the latter contents will be used to determine the Etag value. The reverse router also uses the digest in order to translate any file to the form <digest>-<asset> for example "a.js" may be also found at "d41d8cd98f00b204e9800998ecf8427e-a.js". If there is no digest file found then digest values for ETags are formed by forming a sha1 digest of the last-modified time.

The default digest algorithm to search for is "md5". You can override this quite easily. For example if the SHA-1 algorithm is preferred:

"play.assets.digest.algorithm" = "sha1"

You can set a custom Cache directive for a particular resource if needed. For example in your application.conf file:

"play.assets.cache./public/images/logo.png" = "max-age=3600"

You can use this controller in any application, just by declaring the appropriate route. For example:

GET     /assets/\uFEFF*file               controllers.Assets.at(path="/public", file)
Source
Assets.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Assets
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. case class Asset(name: String) extends Product with Serializable

    An asset.

    An asset.

    name

    The name of the asset.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val alternativeDateFormatWithTZOffset: DateTimeFormatter
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. def parseModifiedDate(date: String): Option[Date]
  17. val standardDateParserWithoutTZ: DateTimeFormatter
  18. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  19. def toString(): String
    Definition Classes
    AnyRef → Any
  20. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  23. object Asset extends Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped