Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.
Cache-aware Server Push
in H2O version 1.5
Kazuho Oku
DeNA Co., Ltd.
1Cache-aware Server Push in H2O version 1.5
Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.
Finding out what is NOT cached
2Cache-aware Server Push in H2O version 1.5
Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.
Cache Fingerprinting
 include in every HTTP request a fingerprint of
the cached blocking assets (e.g. CSS and script files)
belonging to the same origin
⁃ server uses the fingerprint to determine what
should be pushed
 algorithm: Golomb compressed sets
⁃ compressed form of Bloom filter
⁃ key(asset) = sha1(asset_URL + asset_etag)
⁃ estimated size: 1.x * N * log2(1/P) bits
⁃ N: # of entries, P: possibility of false positive
⁃ e.g. 800 bits for 100 asset files, 1% false positive
3Cache-aware Server Push in H2O version 1.5
Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.
Calculating the Fingerprint
 ServiceWorker
⁃ iterate though the SW cache and calculate
⁃ the issue: SW may not be running
• esp. for first visit or returning user (after some time),
in which case we need to push things
 Cookie
⁃ calculate in server, and set it as a Cookie
⁃ can always be used
⁃ the issue: can't update when a cache entry gets
purged
• means there might be false positives
4Cache-aware Server Push in H2O version 1.5
Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.
Calculating the Fingerprint
 hybrid approach
⁃ use Cookie header to send the fingerprint
⁃ store response in SW cache whenever possible
• even if SW is not activated (yet)
⁃ in SW, always recalculate the fingerprint and
update the Cookie
• so that the values becomes precise
5Cache-aware Server Push in H2O version 1.5
Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.
Cookie-based impl. in H2O version 1.5
 tracking issue: github.com/h2o/h2o/issues/421
⁃ thanks to Jxck, Ilya, Tatsuhiro for the feedbacks!
 H2O cancels push indications sent from backend, if
client is likely to already have the data in cache
 hybrid impl. in the works
6Cache-aware Server Push in H2O version 1.5
Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.
Configuration (H2O 1.5)
mruby.handler: |
lambda do |env|
push_paths = []
if /(/|.html)$/.match(env["PATH_INFO"])
push_paths << "/search/jquery-1.9.1.min.js"
push_paths << "/search/oktavia-jquery-ui.js"
...
end
return [
399, # delegate the request to next handler
push_paths.empty? ? {}
: {"link" =>
push_paths.map{|p| "<#{p}>; rel=preload"}.join("n")},
[]
]
end
file.dir: /path/to/doc-root
7Cache-aware Server Push in H2O version 1.5
Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.
Demo
 Web server (H2O) tracks the cache fingerprint
⁃ and cancels the push if the client has the asset
• or, we might push 304
⁃ or actually does the push if otherwise
8Cache-aware Server Push in H2O version 1.5
Copyright (C) 2015 DeNA Co.,Ltd. All Rights Reserved.
Benchmark scores
 first-paint does not change
⁃ reason: no dependency chain bet. assets,
packets arriving in batch for every RTT
 unload is delayed (since assets arrive before HTML)
9Cache-aware Server Push in H2O version 1.5

Cache aware-server-push in H2O version 1.5

  • 1.
    Copyright (C) 2015DeNA Co.,Ltd. All Rights Reserved. Cache-aware Server Push in H2O version 1.5 Kazuho Oku DeNA Co., Ltd. 1Cache-aware Server Push in H2O version 1.5
  • 2.
    Copyright (C) 2015DeNA Co.,Ltd. All Rights Reserved. Finding out what is NOT cached 2Cache-aware Server Push in H2O version 1.5
  • 3.
    Copyright (C) 2015DeNA Co.,Ltd. All Rights Reserved. Cache Fingerprinting  include in every HTTP request a fingerprint of the cached blocking assets (e.g. CSS and script files) belonging to the same origin ⁃ server uses the fingerprint to determine what should be pushed  algorithm: Golomb compressed sets ⁃ compressed form of Bloom filter ⁃ key(asset) = sha1(asset_URL + asset_etag) ⁃ estimated size: 1.x * N * log2(1/P) bits ⁃ N: # of entries, P: possibility of false positive ⁃ e.g. 800 bits for 100 asset files, 1% false positive 3Cache-aware Server Push in H2O version 1.5
  • 4.
    Copyright (C) 2015DeNA Co.,Ltd. All Rights Reserved. Calculating the Fingerprint  ServiceWorker ⁃ iterate though the SW cache and calculate ⁃ the issue: SW may not be running • esp. for first visit or returning user (after some time), in which case we need to push things  Cookie ⁃ calculate in server, and set it as a Cookie ⁃ can always be used ⁃ the issue: can't update when a cache entry gets purged • means there might be false positives 4Cache-aware Server Push in H2O version 1.5
  • 5.
    Copyright (C) 2015DeNA Co.,Ltd. All Rights Reserved. Calculating the Fingerprint  hybrid approach ⁃ use Cookie header to send the fingerprint ⁃ store response in SW cache whenever possible • even if SW is not activated (yet) ⁃ in SW, always recalculate the fingerprint and update the Cookie • so that the values becomes precise 5Cache-aware Server Push in H2O version 1.5
  • 6.
    Copyright (C) 2015DeNA Co.,Ltd. All Rights Reserved. Cookie-based impl. in H2O version 1.5  tracking issue: github.com/h2o/h2o/issues/421 ⁃ thanks to Jxck, Ilya, Tatsuhiro for the feedbacks!  H2O cancels push indications sent from backend, if client is likely to already have the data in cache  hybrid impl. in the works 6Cache-aware Server Push in H2O version 1.5
  • 7.
    Copyright (C) 2015DeNA Co.,Ltd. All Rights Reserved. Configuration (H2O 1.5) mruby.handler: | lambda do |env| push_paths = [] if /(/|.html)$/.match(env["PATH_INFO"]) push_paths << "/search/jquery-1.9.1.min.js" push_paths << "/search/oktavia-jquery-ui.js" ... end return [ 399, # delegate the request to next handler push_paths.empty? ? {} : {"link" => push_paths.map{|p| "<#{p}>; rel=preload"}.join("n")}, [] ] end file.dir: /path/to/doc-root 7Cache-aware Server Push in H2O version 1.5
  • 8.
    Copyright (C) 2015DeNA Co.,Ltd. All Rights Reserved. Demo  Web server (H2O) tracks the cache fingerprint ⁃ and cancels the push if the client has the asset • or, we might push 304 ⁃ or actually does the push if otherwise 8Cache-aware Server Push in H2O version 1.5
  • 9.
    Copyright (C) 2015DeNA Co.,Ltd. All Rights Reserved. Benchmark scores  first-paint does not change ⁃ reason: no dependency chain bet. assets, packets arriving in batch for every RTT  unload is delayed (since assets arrive before HTML) 9Cache-aware Server Push in H2O version 1.5

Editor's Notes

  • #4 we only track the blocking asset files to keep the fingerprint small
  • #10 the rows marked "reprio:on" are the responses that sent blocking asset files prior to images, regardless of whether push or pull