PHP cannot use header cache
欧阳克
欧阳克 2017-06-30 09:56:14
0
1
705
<?php
header("Cache-Control: public");
header("Pragma: cache");
$offset = 30*60*60*24; // cache 1 month
$ExpStr = "Expires: ".gmdate("D, d M Y H:i:s", time() + $offset)." GMT";
header($ExpStr);
echo date("Y-m-d l H:i:s A");
?>

I set up a cache for one month, but the display time is different every time I refresh it. What's wrong with the code?

欧阳克
欧阳克

温故而知新,可以为师矣。 博客:www.ouyangke.com

reply all(1)
刘奇

Every time the page is refreshed, you send the Header, and of course it is updated every time.

If there is a cache header on the http header,
When the browser requests this page, it will bring request headers such as If-Modified, If-Match, etc.
You need to judge based on the content in the If header, yes Send 304 Not Modified or send a new page.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template