如何从php浏览器缓存图像 [英] How to browser cache image from php
本文介绍了如何从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>
产品图片网址示例:
我该怎么做?
推荐答案
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屋!
查看全文