简体   繁体   English

来自PHP脚本的mod_expires和图像

[英]mod_expires and images from php script

I have a php script which returns images with a specific id. 我有一个php脚本,该脚本返回具有特定ID的图像。

getImage.php?id=12

I configured some mod_expires preferences. 我配置了一些mod_expires首选项。 In example. 例如。

ExpiresByType image/gif "access plus 1 minute"
ExpiresByType image/jpeg "access plus 1 minute"
ExpiresByType image/jpg "access plus 1 minute"
ExpiresByType image/png "access plus 1 minute"

When i look in my chrome developer tools it works on static images but not on the images requested over my php script. 当我在chrome开发人员工具中查看时,它可以在静态图片上使用,但不能在通过我的PHP脚本请求的图片上使用。

Am i doing anything wrong or what is the problem? 我是在做错什么还是什么问题?

Thanks for helping 感谢您的帮助

You need to set right MIME type and Cache-Control headers inside your getImage.php. 您需要在getImage.php中设置正确的MIME类型和Cache-Control标头。

header('Content-type: image/jpeg');
header('Cache-Control: max-age=60');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM