如何从php浏览器缓存图像 [英] How to browser cache image from php

查看:172
本文介绍了如何从php浏览器缓存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的是德美.关于产品有很多图片.但是这些图像来自一个php文件(imgtag.php),因此我不能用此代码强制浏览器将产品图像带入缓存:

I use virtuemart. There are a lot of images about the products. But this images come from a php file(imgtag.php), so I can't force the browser with this code to take the product images to the cache:

<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|ttf|eot|swf)$">
   Header set Cache-Control "max-age=2592000"
</FilesMatch>

产品图片网址示例:

http://://www.myshop.com/components/com_virtuemart/show_image_in_imgtag.php?filename = be6160cc3ede6b58d13f4adaa61f49f7.jpg& newxsize = 120& newysize = 120& fileout =

我该怎么做?

推荐答案

您可以修改您的imgtag.php文件,以便它使用PHP

You could modify your imgtag.php file, so it sends that header, using the PHP header() function :

header('Cache-Control: max-age=2592000');

注意:设置标头必须在任何输出之前完成.

这篇关于如何从php浏览器缓存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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