Upgrade to Pro — share decks privately, control downloads, hide ads and more …

日経電子版へのPWA導入事例

Ryo yasuda
October 31, 2018

 日経電子版へのPWA導入事例

Ryo yasuda

October 31, 2018
Tweet

More Decks by Ryo yasuda

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ ҆ా ཽ (΍ͩ͢ Γΐ͏) 2015೥: NTTݚڀॴ ೖࣾ - ίϯςφܕԾ૝Խٕज़ؔ࿈ͷݚڀʹैࣄ

    2016೥: ೔ຊܦࡁ৽ฉࣾ ೖࣾ - ೔ܦిࢠ൛ϦχϡʔΞϧ൛ ։ൃϝϯόʔ - ϑϩϯτΤϯυɾόοΫΤϯυɾΠϯϑϥ౳ॾʑ୲౰ Α͘ॻ͘ݴޠ: js, golang, python
  2. ϦχϡʔΞϧʹΑΔޮՌ •58% better conversion rate •40% more daily active user

    •2x faster Speed Index •14 seconds faster Time-To-Interactive •2.3x organic traffic
  3. PWAͱ͸ – GoogleʹΑΔఆٛ • Fast • ϖʔδͷϩʔυ଎౓ɾԠ౴଎౓͕଎͍ • Reliable •

    ωοτϫʔΫঢ়گʹґଘ͠ͳ͍(ΦϑϥΠϯͰ΋ར༻Մೳ) • Engaging • ϓογϡ௨஌ • ϗʔϜը໘΁ͷ௥Ճ https://developers.google.com/web/progressive-web-apps/checklist
  4. ϑΝʔετϏϡʔදࣔ଎౓ͷ࠷దԽ – PRPLύλʔϯ • Push: ϑΝʔετϏϡʔͷඳըʹඞཁͳϦιʔεΛPush • Render: ϑΝʔετϏϡʔΛඳը •

    Pre-cache: ࣍ʹඞཁͳϦιʔε΍ϖʔδΛPre-cache • Lazyload: ϑΝʔετϏϡʔ֎ͷίϯςϯπΛLazyload *Googleͷఏএ͢ΔSPAΛલఏͱͨ͠PRPLύλʔϯͱ͸ҟͳΔ΋ͷͷࢀߟʹ͍ͯ͠Δ
  5. ϑΝʔετϏϡʔදࣔ଎౓ͷ࠷దԽ – PRPLύλʔϯ • Push: ϑΝʔετϏϡʔͷඳըʹඞཁͳϦιʔεΛPush • Render: ϑΝʔετϏϡʔΛඳը •

    Pre-cache: ࣍ʹඞཁͳϦιʔε΍ϖʔδΛPre-cache • Lazyload: ϑΝʔετϏϡʔ֎ͷίϯςϯπΛLazyload *Googleͷఏএ͢ΔSPAΛલఏͱͨ͠PRPLύλʔϯͱ͸ҟͳΔ΋ͷͷࢀߟʹ͍ͯ͠Δ
  6. • HTTP/2 Server H2OΛར༻ • Link HeaderʹϦιʔεΛهड़͢ΔͱPushͯ͘͠ΕΔ HTTP/2 Server Push

    Origin Server H2O Client Link:<bundle.js>;rel=preload;, <bundle.css>; rel=preload; Push: bundle.css Push: bundle.js
  7. • Fastly(CDN)͕LinkϔομΛ࢖ͬͨPushΛαϙʔτ • r.nikkeiͰ͸Fastly࢖ͬͯͨͷͰPushͷಋೖͷखؒ͸খ͍͞ HTTP/2 Server Push Origin Server Fastly

    (CDN) Client Link:<bundle.js>;rel=preload;, <bundle. css>; rel=preload; Push: bundle.css Push: bundle.js
  8. ϑΝʔετϏϡʔදࣔ଎౓ͷ࠷దԽ – PRPLύλʔϯ • Push: ϑΝʔετϏϡʔͷඳըʹඞཁͳϦιʔεΛPush • Render: ϑΝʔετϏϡʔΛඳը •

    Pre-cache: ࣍ʹඞཁͳϦιʔε΍ϖʔδΛPre-cache • Lazyload: ϑΝʔετϏϡʔ֎ͷίϯςϯπΛLazyload *Googleͷఏএ͢ΔSPAΛલఏͱͨ͠PRPLύλʔϯͱ͸ҟͳΔ΋ͷͷࢀߟʹ͍ͯ͠Δ
  9. Render – Critical Rendering Pathͷ࠷దԽ Request Page Start building DOM

    Build CSSOM Run JS Continue Building DOM Render Page GET html Response Response Response GET css GET js
  10. Render – Critical Rendering Pathͷ࠷దԽ Request Page Start building DOM

    Build CSSOM Run JS GET html Response Response Response GET css GET js
  11. Render – Critical Rendering Pathͷ࠷దԽ Request Page Start building DOM

    Build CSSOM Run JS Continue Building DOM GET html Response Response Response GET css GET js
  12. Render – Critical Rendering Pathͷ࠷దԽ Request Page Start building DOM

    Build CSSOM Run JS Continue Building DOM Render Page GET html Response Response Response GET css GET js
  13. Render – Critical Rendering Pathͷ࠷దԽ Request Page Start building DOM

    Build CSSOM Run JS Continue Building DOM Render Page GET html Response Response Response GET css GET js CSSϒϩοΩϯά JSϒϩοΩϯά
  14. Render – async/defer <script src= ”/bundle.js” async> <script src=”/bundle.js” defer>

    • r.nikkei͸non-SPA+SSRͳͷͰϑΝʔετϏϡʔදࣔʹjs͸ෆཁ • jsͷ࣮ߦ͸ը໘දࣔޙͰे෼ • async/deferͰjsͷಡΈࠐΈɾ࣮ߦλΠϛϯάΛมߋ
  15. Render – Critical Rendering Pathͷ࠷దԽ Request Page Start building DOM

    Build CSSOM Run JS Continue Building DOM Render Page GET html Response Response Response GET css GET js
  16. Render – Critical Rendering Pathͷ࠷దԽ Request Page Build CSSOM Run

    JS Continue Building DOM Render Page GET Html + Critical CSS Response Response GET js Start building DOM
  17. ϑΝʔετϏϡʔදࣔ଎౓ͷ࠷దԽ – PRPLύλʔϯ • Push: ϑΝʔετϏϡʔͷඳըʹඞཁͳϦιʔεΛPush • Render: ϑΝʔετϏϡʔΛඳը •

    Pre-cache: ࣍ʹඞཁͳϦιʔε΍ϖʔδΛPre-cache • Lazyload: ϑΝʔετϏϡʔ֎ͷίϯςϯπΛLazyload *Googleͷఏএ͢ΔSPAΛલఏͱͨ͠PRPLύλʔϯͱ͸ҟͳΔ΋ͷͷࢀߟʹ͍ͯ͠Δ
  18. Resource Hints • ࣍ʹඞཁͱͳΔϦιʔεΛࣄલʹ४උ͢ΔͨΊͷAPI • dns-prefetch: DNSʹΑΔ໊લղܾΛࣄલʹߦ͏ • preconnect :

    TCP઀ଓΛࣄલʹߦ͏ • prefetch : ࣄલʹίϯςϯπΛऔಘͯ͠Ωϟογϡ • prerender : ϖʔδશମΛࣄલʹϨϯμϦϯά ྫ: <link rel="preconnect" href="//example.com">
  19. ϑΝʔετϏϡʔදࣔ଎౓ͷ࠷దԽ – PRPLύλʔϯ • Push: ϑΝʔετϏϡʔͷඳըʹඞཁͳϦιʔεΛPush • Render: ϑΝʔετϏϡʔΛඳը •

    Pre-cache: ࣍ʹඞཁͳϦιʔε΍ϖʔδΛPre-cache • Lazyload: ϑΝʔετϏϡʔ֎ͷίϯςϯπΛLazyload *Googleͷఏএ͢ΔSPAΛલఏͱͨ͠PRPLύλʔϯͱ͸ҟͳΔ΋ͷͷࢀߟʹ͍ͯ͠Δ
  20. ΦϑϥΠϯͰ΋ϢʔβߦಈΛτϥοΩϯάͰ͖Δ • Background Sync • ΦϑϥΠϯ࣌ʹૹ৴ͨ͠ϦΫΤετΛΦϯϥΠϯ෮ؼ࣌ʹ࠶ૹ • τϥοΩϯά༻ͷσʔλΛBackground SyncͰૹ৴ •

    ΦϑϥΠϯ࣌ͷهࣄอଘɾίϝϯτ౤ߘͳͲʹ΋Ԡ༻Մೳ ϦΫΤετΛ อଘ ϒϥ΢β Indexed DB Server Service Worker Background Sync ͷొ࿥ ΦϯϥΠϯ෮ؼ·Ͱ଴ػ ϦΫΤετΛ ૹ৴
  21. WorkboxͰग़དྷΔ͜ͱ • SWͰ΍Γ͍ͨجຊతͳࣄ͸֓Ͷ࣮૷͞Ε͍ͯΔ • Precaching • Runtime caching • Cache

    Strategies (stale-while-revalidateͱ͔) • Request routing • Background sync • ϩά͕਌੾Ͱڍಈ͕ͱͯ΋Θ͔Γ΍͍͢