General Browser request PHP is not cached unless PHP directly displays the Send head 304
if (Isset ($_server[' http_if_modified_since ')) {$browserCachedCopyTimestamp = Strtotime (Preg_replace ('/;. *$/', ', $_server[' http_if_modified_since ')), IF ($browserCachedCopyTimestamp + 604800 > Time ()) {header ("http/1.1 304 not Modified"); header ("Expires:".) Gmdate ("R", (Time () + 604800)), header ("cache-control:max-age=604800"); Exit;}} $id =i (' Get.id ', 0, ' intval '); $file = Upload_img_path. ' qccode/'. $id. '. png '; if (file_exists ($file)) {header ("last-modified:".) Gmdate (' R ', Time () ));header ("Expires:".) Gmdate ("R", (Time () + 604800)), header ("cache-control:max-age=604800");header ("Pragma:public");Header ("Content-type:image/png"); Echo file_get_contents ($file);} else{$QR = \applib\get_app_lib (' Phpqrcode ', false); $site = C (' Site_url '); $value = $site. $id. '. html '; $errorCorrectionLevel = "L"; $matrixPointSize = "4.5"; \qrcode::p ng ($value, $file, $errorCorrectionLevel, $ matrixpointsize); Echo file_get_contents ($file);}
Above is through the 304来 cache a dynamic JS, according to the file modification time to judge, here need to note, if again before there is session_start, pay attention to Session_cache_limiter, he will send a non-cached header information.
This situation needs to be able to force send a program to the public's head to circumvent, note that when sending 304, it is better to add the cache header, I can not reset the cache js, perhaps because I am a server redirection simulation of the dynamic JS bar (the request path is JS, but is generated dynamically )。
304 Ways of PHP