<?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?
怪我咯2017-06-30 09:58:14
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.