简体   繁体   中英

Azure Storage Account Static Website takes lot of time to load

I have deployed my Single Page Applicate built in Angular in Azure Storage Account Static Website. But it takes lot of time to load the website initially. After investigation I found that it takes about 1.2 min to load one js file - main.af203c3f3d3f3672aa00.js which is only 4.8MB in size. Also in the response header I can see only the below headers -

Accept-Ranges: bytes
Content-Length: 4787902
Content-MD5: n+dgJsZM2T10m0hxWEpjJw==
Content-Type: text/javascript
Date: Tue, 21 Jul 2020 13:06:45 GMT
ETag: "0x8D82CBF6D4B3910"
Last-Modified: Mon, 20 Jul 2020 15:13:15 GMT
Server: Windows-Azure-Web/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 6ea1da4a-e01e-0045-0b5f-5f06fe000000
x-ms-version: 2018-03-28

The Content-Encoding: gzip this is not set. Which is why it is taking this much time to download the content of 4.8MB.

I have checked in the azure portal, did not find any option to enable the Content-Encoding . How can I enable the compression for Static Website in Azure Storage Account?

Using Azure Storage Explorer you can set content-type, cache-control, content-encoding on each blob. Convert your.js file to.gzip and then set the correct metadata on the file.

Here is an online tool that can convert javascript to gzip: http://cnvyr.io/online

在此处输入图像描述

Simply setting the content-encoding property of a blob to gzip is not going to help considering you're uploading the file as is.

For this to work, you would need to first compress the file using gzip compression and upload the compressed file in blob storage. You would also need to set the content-encoding property of the blob as 'gzip'.

If you're looking for a 3rd party tool to do so, please take a look at Cerebrata Cerulean ( https://www.cerebrata.com ). It has a feature where you can instruct it to compress files using either gzip or deflate before uploading. It will automatically set the content-encoding property of the blob to 'gzip' or 'deflate' as well.

Full Disclosure: I am working on this application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM