web loading performance optimization with play 2.3 assets pipeline
talk at Play Framework user group in Berlin: http://www.meetup.com/Play-Berlin-Brandenburg/events/203877602/
2. Speed is a feature
● Faster sites lead to better user
engagement
● Faster sites lead to better user retention
● Faster sites lead to higher conversions
Source:
http://chimera.labs.oreilly.com/books/1230000000545/ch01.html#SPEED_FEATURE
5. less bytes (2)
● conditional requests
● Last-Modified and ETag headers provide
validation mechanisms
6. Last-Modified
● Server sets Last-Modified header
● Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
● Browser issues an If-Modified-Since
request header to validate the cached
document
● Server answers with 304 Not Modified
or 200 OK
7. Etag
● Server sets Etag header
● Etag: "15f0fff99ed5aae4edffdd6496d7131f"
● Browser issues an If-None-Match
request header to validate the cached
document
● Server answers with 304 Not Modified
or 200 OK
8. Conditional requests
● Last-modified: based on time
● Etag: based on content
● Since play 2.0.2
9. less requests
● Cache-Control switches on caching in
the browser
● avoid requests
11. real world
● Caching strategies different from browser
to browser
12. perfect world
● in developement: always the last version
● in production:
– cache the assets as long as they are not
modified
– be sure that a browser does not use an
outdated cached asset
13. play 2.3
● pipelineStages := Seq(digest, gzip)
● in production mode
● content-based hash in the filename
● different content -> different fingerprint
● sets a very long cache
14. reduce latency
● Content delivery network (CDN)
● distributes content around globe
● location near from client
● request without cookie
● downside: one more DNS lookup
15. play 2.3
● webjars
● pipelineStages := Seq(rjs, digest, gzip)
● assets from http://cdn.jsdelivr.net/
16. under the cover
● assets pipeline managed with sbt-web
and plugins:
https://github.com/sbt/sbt-web
● not play specific
● versioned assets controller in play 2.3