HTTP:很少更改图像的最佳标头是什么 [英] HTTP: What are the best headers for rarely changed images

查看:135
本文介绍了HTTP:很少更改图像的最佳标头是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有许多小图片显示在用户的个人资料中,并且此页面的加载非常糟糕。最好的解决方案就是全部精灵,但遗憾的是我有太多的图像,每个配置文件只使用几百个。

I have many many small images that are displayed on a user's profile and the loading of this page is horrible. The best solution is to sprite them all, but sadly I have too many images for that and only a few hundred are used per profile.

所以,我正在尝试获得第二个最佳解决方案。我应该发送什么标题? ETag的?过期?缓存控制?现在我有:

So, I'm trying to get the second best solution. What headers should I send? ETag? Expires? Cache-Control? Right now I have:

http: //metaward.com/media/award/ofwjh3.png

Last-Modified   Sat, 11 Jul 2009 22:37:49 GMT
Cache-Control   max-age=2592000
Expires Tue, 29 Sep 2009 22:41:21 GMT

以及包含大量图像的示例页面(显示加载速度有多慢,即使在缓存时):

And an example page with lots of images (to show how slow they load, even when cached) :

http://metaward.com/6

有时候用户也会更改他们的个人资料图片,但只有其中一个,所以我不担心缓存。

Sometimes the user will also change their profile picture, but there is only one of those so I'm not as worried about caching.

推荐答案

在这种情况下,您应该使用远期未来到期来最大化缓存命中。这意味着如果你改变了一个图像,你需要给它一个新的名字,但我无法想象你经常会改变它们,因为有这么多。

In this case you should use a "far future expires" to maximize cache hits. This means if you change an image, you need to give it a new name, but I can't imagine you're changing them often given that there are so many.

页面上确实有100个图像,你应该对它们进行精灵处理。也许有一些更常见的(你推荐的),你可以开始看看它是否有帮助。或许你可以做一些最不可能改变的精灵。

You really have 100s of images on the page, and you should sprite them. Perhaps there are some more common ones (your recommended) that you can start with to see whether it helps. Or maybe you could do a sprite of those "least likely to change".

这篇关于HTTP:很少更改图像的最佳标头是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆