向我的 Web 应用程序添加 gZip 压缩是否会提高加载大图像的性能?

发布于 2024-12-14 10:16:42 字数 1326 浏览 5 评论 0原文

我有一个 Web 应用程序,其中包含一个幻灯片放映,其中包含大约 10 张大图像 (100-200k) 图像。我听说有人过去使用 gZip http 压缩来帮助提高网站的性能,所以我开始对此进行一些研究。我最终发现 下面的 web.config snipit 声称可以做到这一点:

<system.webServer>
  <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
    <dynamicTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/javascript" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </dynamicTypes>
    <staticTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/javascript" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </staticTypes>
  </httpCompression>
  <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>

但是仔细观察后,这似乎对图像没有任何作用。

对图像 mimeTypes 使用 gZip 压缩是否有效,或者我是否会浪费时间将其添加到上面?谁能推荐任何改善大图像加载时间的好策略?

旁注:不确定这是否有什么不同,但该网站托管在 goDaddy 上。

I have a web app that contains a slide show with about 10 large images (100-200k) images. I've heard of people using gZip http compression to help improve the performance of their websites in the past so I started doing a little research on this. I ended up finding the following web.config snipit that claims to do this:

<system.webServer>
  <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
    <dynamicTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/javascript" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </dynamicTypes>
    <staticTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/javascript" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </staticTypes>
  </httpCompression>
  <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>

But after looking at it a little closer this does not appear to do anything for images.

Is using gZip compression for image mimeTypes effective or would I be wasting my time to add it to the above? Can anyone recommend any good strategies for improving the load time of large images?

Side note: Not sure if it makes a difference but the site is hosted on goDaddy.

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

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

发布评论

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

评论(2

无法回应 2024-12-21 10:16:42

JPG图像、GIF等已经是压缩格式。进一步压缩它们不会有太大帮助。您应该考虑缓存它们,以便每次对同一图像发出请求时 Web 服务器都会返回 304 响应。

顺便说一句,您发布的 Web.config 没有对图像进行压缩(因为它没有帮助)。

更新

配置 IIS 返回 HTTP 304 状态代码对于某些文件类型。

JPG images, GIF, etc are already compressed formats. Compressing them further isn't going to help much. You should be looking into caching them instead so that the web server returns 304 responses every time a request for the same image is made.

By the way, the Web.config that you posted is not doing compression on images (as it doesn't help).

UPDATE

Configure IIS to return HTTP 304 Status codes on certain file types.

小嗷兮 2024-12-21 10:16:42

JPEG 格式是一种压缩格式。所以不需要再次压缩。考虑压缩脚本和 CSS。

使用SquishIt用于压缩 javascript 和 CSS。

尝试使用来自 Yahoo 的 SmushIt 来优化图像

The JPEG format is a compressed format. So no need to compress it again. Think about compressing scripts and css.

Use SquishIt for compressing javascript and CSS.

Try SmushIt from Yahoo to optimise the images

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