Home > Backend Development > PHP Tutorial > 304 - 用php输出图片,怎么让浏览器缓存?

304 - 用php输出图片,怎么让浏览器缓存?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:23:29
Original
1244 people have browsed it

设置了Expires和Cache-Control后在浏览器调试工具查看都没有缓存,应该怎么办?

回复内容:

设置了Expires和Cache-Control后在浏览器调试工具查看都没有缓存,应该怎么办?

在.htaccess文件中加入如下代码:

<code>1: # Image and Flash content Caching for One Month
2: <filesmatch>
3: Header set Cache-Control "max-age=2592000"
4: </filesmatch>
</code>
Copy after login

编辑完毕后保存文件。 代码中“max-age”参数的值为2592000(秒),因此图片缓存和Flash内容缓存在浏览器中保留一个月。

304 - 用php输出图片,怎么让浏览器缓存?

header("Cache-Control:3600");
Copy after login

chrome调试工具有个Disable cache,你看看是否选中。

问题已经解决,设置没问题,清空缓存就好了。

为什么要输出图片,保存成uri不是更好吗?

可以返回302状态

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template