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

Firebase Hosting & HTTP2 Server Push

Firebase Hosting & HTTP2 Server Push

#ng_kyoto Angular Meetup #8(https://ng-kyoto.connpass.com/event/100685/) でFirebase HostingでHTTP/2 Server Pushができることを紹介しました

Masashi Hirano

October 06, 2018
Tweet

More Decks by Masashi Hirano

Other Decks in Technology

Transcript

  1. Angularͱfirebaseͷ४උ $ npm install -g @angular/cli firebase-tools $ ng new

    my-angular-app $ cd my-angular-app $ ng build —prod $ firebase init πʔϧͷΠϯετʔϧ "OHVMBSΞϓϦ࡞੒Ϗϧυ pSFCBTFͷઃఆॳظԽ
  2. σΟϨΫτϦߏ੒ my-angular-app !"" README.md !"" angular.json !"" e2e !"" firebase.json

    !"" package-lock.json !"" package.json !"" src !"" tsconfig.json #"" tslint.json pSFCBTFJOJUͰੜ੒͞ΕͨઃఆϑΝΠϧ
  3. firebase.json { "hosting": { "public": “dist/my-angular-app“, "ignore": [ "firebase.json", “**/.*",

    "**/node_modules/**" ] } } σϓϩΠ͢ΔσΟϨΫτϦ Λࢦఆ σϓϩΠ࣌ʹແࢹ͢ΔϑΝΠϧΛࢦఆ
  4. $ firebase deploy === Deploying to 'my-angular-app-d2e19'... i deploying hosting

    i hosting[my-angular-app-d2e19]: beginning deploy... i hosting[my-angular-app-d2e19]: found 8 files in dist/my- angular-app ✔ hosting[my-angular-app-d2e19]: file upload complete i hosting[my-angular-app-d2e19]: finalizing version... ✔ hosting[my-angular-app-d2e19]: version finalized i hosting[my-angular-app-d2e19]: releasing new version... ✔ hosting[my-angular-app-d2e19]: release complete ✔ Deploy complete! Project Console: https://console.firebase.google.com/project/my- angular-app-d2e19/overview Hosting URL: https://my-angular-app-d2e19.firebaseapp.com FirebaseʹσϓϩΠ pSFCBTFEFQMPZΛ࣮ߦ
  5. Server Push͢ΔͨΊʹ • headersΛfirebase.jsonʹ௥Ճ • ೚ҙͷϨεϙϯεϔομʔΛ௥ՃͰ͖Δ • LinkϔομʔΛ௥Ճ • key:

    “Link” • value: <Push͍ͨ͠ϑΝΠϧͷύε>;rel=preload;as=script • e.g. </main.js>;rel=preload;as=script
  6. firebase.json { "hosting": { "headers": [ { "source": "/", "headers":

    [{ "key": “Link", "value": "</main.js>;rel=preload;as=script,</ runtime.js>;rel=preload;as=script,</ polyfills.js>;rel=preload;as=script,</ styles.css>;rel=preload;as=style" }] } ] } } IFBEFSTΛ௥Ճ