Sports Performance Brand ‘Pure Play’ Inaugurated - Vishnu Bhagat , About Vishnu Bhagat
Web performance-play-2.3
Click here to load reader
-
Upload
yanns -
Category
Technology
-
view
329 -
download
5
description
Transcript of Web performance-play-2.3
![Page 1: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/1.jpg)
web performance
assets pipeline in Play 2.3
![Page 2: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/2.jpg)
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
![Page 3: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/3.jpg)
better performance
● less bytes● less requests● less latency
![Page 4: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/4.jpg)
less bytes (1)
● gzip encoding● doc:
https://www.playframework.com/documentation/latest/GzipEncoding
![Page 5: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/5.jpg)
less bytes (2)
● conditional requests● Last-Modified and ETag headers provide
validation mechanisms
![Page 6: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/6.jpg)
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
![Page 7: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/7.jpg)
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
![Page 8: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/8.jpg)
Conditional requests
● Last-modified: based on time
● Etag: based on content
● Since play 2.0.2
![Page 9: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/9.jpg)
less requests
● Cache-Control switches on caching in the browser
● avoid requests
![Page 10: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/10.jpg)
Cache-Control
● Cache-Control:public
● Cache-Control:private
● Cache-Control:public, max-age=31536000
● Cache-Control:public
Expires: Mon, 25 Jun 2012 21:31:12 GMT
![Page 11: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/11.jpg)
real world
● Caching strategies different from browser to browser
![Page 12: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/12.jpg)
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
![Page 13: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/13.jpg)
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
![Page 14: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/14.jpg)
reduce latency
● Content delivery network (CDN)● distributes content around globe● location near from client● request without cookie● downside: one more DNS lookup
![Page 15: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/15.jpg)
play 2.3
● webjars● pipelineStages := Seq(rjs, digest, gzip)
● assets from http://cdn.jsdelivr.net/
![Page 16: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/16.jpg)
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
![Page 18: Web performance-play-2.3](https://reader038.fdocuments.net/reader038/viewer/2022100602/558c59c4d8b42a402c8b4685/html5/thumbnails/18.jpg)
web perf - more info
● High Performance Browser Networkinghttp://chimera.labs.oreilly.com/books/1230000000545/index.html
● https://devcenter.heroku.com/articles/increasing-application-performance-with-http-cache-headers
● https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching