background image

//最后修改时间(在缓存的时候可以用到)
// last modified (good for caching) 
$time = time() - 60; // or filemtime($fn), etc 
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT'); 

// 告诉浏览器要获取的内容还没有更新
// header for telling the browser that the content 
// did not get changed 
header('HTTP/1.1 304 Not Modified'); 

// 

 

设置内容的长度 (缓存的时候可以用到):

// set content length (good for caching): 
header('Content-Length: 1234'); 

// 用来下载文件:
// Headers for an download: 
header('Content-Type: application/octet-stream'); 
header('Content-Disposition: attachment; filename="example.zip"'); 
header('Content-Transfer-Encoding: binary'); 

// 禁止缓存当前文档:
// load the file to send:readfile('example.zip'); 
// Disable caching of the current document: 
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate'); 
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
// 设置内容类型:
// Date in the pastheader('Pragma: no-cache'); 
// set content type: 
header('Content-Type: text/html; charset=iso-8859-1'); 
header('Content-Type: text/html; charset=utf-8'); 
header('Content-Type: text/plain'); 

// plain text file 
header('Content-Type: image/jpeg'); 

// JPG picture 
header('Content-Type: application/zip'); 

// ZIP file 
header('Content-Type: application/pdf'); 

// PDF file