PHP输出图片文件,实现浏览器缓存机制
1 $ETag = '"'.md5($file).'"'; 2 if(env('HTTP_IF_NONE_MATCH') === $ETag){ 3 header ( 'ETag: '.$ETag, true, 304 ); 4 exit; 5 } else { 6 header ( 'ETag: '.$ETag ); 7 readfile ( $file ); 8 exit; 9 }
Your future depends on your dreams. So go to sleep.
1 $ETag = '"'.md5($file).'"'; 2 if(env('HTTP_IF_NONE_MATCH') === $ETag){ 3 header ( 'ETag: '.$ETag, true, 304 ); 4 exit; 5 } else { 6 header ( 'ETag: '.$ETag ); 7 readfile ( $file ); 8 exit; 9 }