saltbo / blog

Repo of my blog
https://saltbo.cn
MIT License
7 stars 0 forks source link

text/javascript vs application/javascript #27

Closed saltbo closed 2 years ago

saltbo commented 4 years ago

问题描述

阿里云OSS针对js文件的gzip只对mime-type是application/javascript才有效。

在uptoc中使用了Golang的mime包,在本地测试时发现js对应的是application/javascript没有问题,但是在GitHubAction中却是text/javascript

问题排查

经过排查发现,在Golang 1.14版本中已经将application/javascript替换成了text/javascript,具体详见https://github.com/golang/go/commit/99df76f0869f00ad9ba53e3aecc22d625ae23de1#diff-bbab6cb33189f1aa348f52c5ad910da8

排查过程中受到一个回答的误导,见https://cloud.tencent.com/developer/ask/52563

里面有人说text/javascript 已过时,但实际情况是按照最新的HTML标准,即将废弃的是application/javascript,以后都应该使用text/javascript

结论