jruusu / play-scala-2.3-cached-result-headers

Trial of a few tricks with cache control headers in a Play 2.3 app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache control in a Play 2.3 (Scala) application

Problem 1: Appropriate result cache duration varies

Solution: Set the Expires header in Action code, and determine cache duration as a function of ResponseHeader (see Application.cacheDurationFromExpiresHeader).

Problem 2: We need Cache-Control: max-age but Cached doesn't set it

Solution: Wrap Cached in another EssentialAction that adds the Cache-Control header and current max-age to the cached result (see Application.WithCacheControl).

About

Trial of a few tricks with cache control headers in a Play 2.3 app

License:Other


Languages

Language:Scala 86.1%Language:HTML 11.9%Language:JavaScript 2.0%