Azure CDN + Asp.net MVC Cloud Service compression for bundles not working
I am using Azure CDN which is pointing to my Azure Cloud Service. I have enabled bundling for my JS and CSS files, and in BundleConfig I have set bundles.UseCdn = true
.
Everything is working fine, except that JS & CSS bundles returned via CDN are not compressed. If I am not using CDN, bundles are returned compressed (I can see that Content-Encoding is gzip).
I have enabled compression on my CDN as you can see in pic below:
And in my ASP.net MVC web.config compression is also enabled, and it looks like this:
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<httpCompression>
<dynamicTypes>
<clear/>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="text/javascript" enabled="true" />
<add mimeType="text/css" enabled="true" />
<add mimeType="application/json" enabled="true" />
<!-- HERE -->
<add mimeType="image/svg+xml" enabled="true" />
<add mimeType="image/png" enabled="true" />
<add mimeType="image/jpg" enabled="true" />
<add mimeType="image/jpeg" enabled="true" />
<add mimeType="application/font-woff2" enabled="true" />
<add mimeType="application/x-font-ttf" enabled="true" />
<add mimeType="application/octet-stream" enabled="true" />
<!-- HERE -->
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<clear/>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="text/javascript" enabled="true" />
<add mimeType="text/css" enabled="true" />
<add mimeType="application/atom+xml" enabled="true" />
<add mimeType="application/xaml+xml" enabled="true" />
<!-- HERE -->
<add mimeType="image/png" enabled="true" />
<add mimeType="image/jpg" enabled="true" />
<add mimeType="image/jpeg" enabled="true" />
<add mimeType="application/font-woff2" enabled="true" />
<add mimeType="application/x-font-ttf" enabled="true" />
<add mimeType="application/octet-stream" enabled="true" />
<!-- HERE -->
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
Interestingly, for same CDN profile (but other endpoint) pictures do have Content-Encoding: gzip, so it seems that compression works fine on CDN also.
This SO answer suggested adding smth. like &group=smth.js
at the end of CDN URL, but that din't help.
So what am I doing wrong?
According to your description, I created my MVC web application to check this issue and I did not configure urlCompression
under my web.config
file.
Without Azure CDN, the css/javascript would be compressed.
For test, I just CDN my whole web app via Azure CDN as follows:
Note: The Compression is enable by default and the formats to compress are the default settings.
Then, access the css/javascript links, they would be compressed as expected.
链接地址: http://www.djcxy.com/p/62728.html