gpt4 book ai didi

php - 强制浏览器缓存图片

转载 作者:可可西里 更新时间:2023-11-01 13:28:53 24 4
gpt4 key购买 nike

我正在生成图像并希望浏览器永远缓存它们,但浏览器根本不缓存它们。这是我的 PHP 代码


header('Content-type:'.$file->content_type);
header('Expires: Thu, 15 Apr '.(date('Y')+10).' 20:00:00 GMT');
header('Content-Disposition: attachment; filename="'.$file->file_name.'"');
echo(file_get_contents($model_files->files_path.$file->md5.$model_files->seprator.$file->file_name));

这些是我不断在浏览器中获取的响应 header 。

Date:            Thu, 02 Jun 2011 12:56:56 GMT
Server: Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By PHP/5.2.15
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma no-cache
Expires Thu, 15 Apr 2021 20:00:00 GMT
Content-Length 321823
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Content-Type image/png

我没有设置 Date、Cache-Control 和 Pragma,但不断让它们响应。

我知道我可以覆盖它们,但老实说我不知道​​要设置哪些值。

最佳答案

关于php - 强制浏览器缓存图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6214965/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com