ySlow、Mod Deflate、cPanel 网站优化器和JavaScript

发布于 2024-08-17 01:53:11 字数 402 浏览 9 评论 0原文

我刚刚开始在我的服务器上安装 mod_deflate 。我还在 cPanel 中的网站优化器中添加了以下内容:

text/html text/plain text/xml text/css text/js text/javascript

现在,该网站在加载时间方面显示出相当大的改进(几乎是 3 倍!),但 ySlow 仍然是给我“使用 gZip 压缩组件”的“E”评级。它显示 4 个 .js 组件未被压缩。

问题在于,除了 .JS 组件之外的整个网站都被正确压缩。其他所有内容,包括内联 javascript、HTML 和其他 MIME 类型都已被压缩。我没有向 htaccess 添加任何内容,因为我认为网站优化工具会处理它。但我还是不明白问题出在哪里?

有什么想法吗?

谢谢,

B.

I just got around to installing mod_deflate on my server. I also added the following to my Website Optimizer in cPanel:

text/html text/plain text/xml text/css text/js text/javascript

Now, the site shows considerable improvement in loading time (almost 3x!), but ySlow is still giving me an "E" rating for "Compress Components with gZip". It shows 4 .js components not being Compressed.

The problem is that the whole website except the .JS components is being gZipped properly. Everything else, including the inline javascript, HTML and other MIME types have been Compressed. I've not added anything to the htaccess, since I think Website Optimizer takes care of it. But I'm still not able to figure out what the problem is?

Any ideas?

Thanks,

B.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤云独去闲 2024-08-24 01:53:11

您是否检查过 JavaScript 所使用的 MIME 类型?您在 gzip 类型列表中列出了 text/javascript,但有时该 MIME 类型不提供 JavaScript;它可能在 text/ecmascriptapplication/x-javascript 下提供,或者可能会获得像 text/plain 这样的默认类型。浏览器通常不关心 Content-Type 中发送的类型,因为它们关注的是

Have you checked what MIME type the JavaScript is being served as? You listed text/javascript in the list of types to gzip, but sometimes JavaScript isn't served under that MIME type; it may be served under text/ecmascript, application/x-javascript, or might be getting a default type like text/plain. Browsers don't generally care what type is sent in the Content-Type, as it's the type listed in the <script> tag that they pay attention to, so the content type for your JavaScript files might be something odd.

百合的盛世恋 2024-08-24 01:53:11

宾果!意识到问题是什么。对于似乎面临同样问题的其他人:

text/javascript MIME 已过时。将其更改为 application/javascript 并且它可以正常工作! :)

Bingo! Realized what the problem is. For anyone else who seems to be facing the same problem:

text/javascript MIME is obsolete. Changed it to application/javascript and it works live a charm! :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文