Add expires header without mod_expires?

徘徊边缘 提交于 2019-12-01 04:20:50

You could use mod_header to set the header field manually:

Header set Expires "..."

But since Expires requires an absolute time, use Cache-Control’s max-age parameter for times relative to the access time:

Header merge Cache-Control max-age=3600

This should tell the browser to refresh the page on subsequent visits. The expires date just has to be in the past... you could set the date using PHP to make it "just" in the past, or just leave it as the date you found this answer!!!

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Thu, 2 Sep 2010 05:00:00 GMT");

UPDATE: Apologies - I missed the "Don't" in the sentence about routing files through PHP! You can also use these HTML meta tags:

<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="Thu, 2 Sep 2010 05:00:00 GMT">
Lekensteyn

If you have static Expires headers, the following will add an Expires header to your js and css files:

<FilesMatch "\.(js|css)$">
Header set Expires "Fri, 01 Jan 2010 00:00:00 GMT"
</FilesMatch>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!