我如何将有效期限添加到img标签? [英] how do I add an expiration date to an img tag?

查看:134
本文介绍了我如何将有效期限添加到img标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Page Speed Firebug扩展程序来帮助提高页面性能。我有一个图片大的页面,其中一个建议是这样的:
$ b


利用浏览器缓存
以下可缓存资源的新鲜度寿命很短。为以下资源至少指定一周到期: com / components / com_arrcard / assets / merchant-logos / aap25.jpgrel =nofollow> http://www.mysite.com/components/com_arrcard/assets/merchant-logos/aap25.jpg (没有指定expiration)

我知道你可以在整页上设置Expires或Cache-Control标题,但是如何将过期添加到特定的元素?这是甚至可能的,或者我误解了什么Page Speed是建议?

解决方案

假设您设置expires或cache-通过在您的网络服务器中使用某种设置(配置特定的目录或使用脚本),以便为每个图像发送的http请求还包含这些属性,从而在图像上显示标题。



如果您使用的是Apache,那么您可以选择 mod_expires


I'm using the Page Speed Firebug extension to help improve page performance. I have an image-heavy page, and one of the suggestions it made is this:

Leverage browser caching The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:

I know you can set Expires or Cache-Control headers on an entire page, but how do I add an expiration to a specific element? Is it even possible, or am I misinterpreting what Page Speed is suggesting?

解决方案

Presumably you'd set the expires or cache-headers on an image by using some sort of setup in your webserver (either configure a specific directory or use a script) so that the http request sent for each image also contains these attributes.

If you're using apache, one option to do this for you is mod_expires.

这篇关于我如何将有效期限添加到img标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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