星期五, 8月 25, 2017

加了 gzip 以後,mp3 檔案無法播放

自從 server 加上了 gzip 處理後,前端頁面的音效 mp3 就出不來了(後來才發現是 gzip 的問題)...

播放時,console 會出現:
Failed to load resource: net::ERR_CONTENT_DECODING_FAILED

看一下 Network,也有帶驚嘆符號的「Provisional headers are shown」字樣


看了一堆文章後,發現跟 gzip 有關,所以去 AWS S3 把 gzip 的 Metadata 拿掉


結果沒用... @@

最後是直接把這個檔案刪除,重新上傳一個沒有 Content-Encoding: gzip 的 mp3 檔案,才解決了這個問題。

星期四, 3月 30, 2017

[Angular] App 是如何開始載入與運行的(進入點)

Angular (2.x/4.x) 入口:main.ts → 透過 bootstrapModule 把 AppModule 綁進來

app.module.ts 裡頭透過 bootstrap array,告訴 angular 有多少 components 要被用到。由於 index.html 裡頭不會引入其他 html 或 css 等資訊,那 angular 是如何知道去哪裡找這些資源?就是透過這個 NgModule 的 declarations,告訴 angular 我們需要用到哪些 components。

其中 app.component.ts 就會定義 Component 的 selector 名稱、html template、css 等內容