First, share the header settings for a file in CI when it is forced to download.
if (Strpos ($_server[' http_user_agent '), "MSIE")!== FALSE)
{
header (' Content-type: '. $mime. ' ");
Header (' Content-disposition:attachment filename= '; $filename. ' ");
Header (' expires:0 ');
Header (' Cache-control:must-revalidate, post-check=0, pre-check=0 ');
Header ("Content-transfer-encoding:binary");
Header (' Pragma:public ');
Header ("Content-length:". strlen ($data));
else
{
header (' Content-type: '. $mime. ' ");
Header (' Content-disposition:attachment filename= '; $filename. ' ");
Header ("Content-transfer-encoding:binary");
Header (' expires:0 ');
Header (' Pragma:no-cache ');
Header ("Content-length:". strlen ($data));
Others are better to understand, mainly about the Cache-control and pragma settings are more confusing.
About Cache-control must-revalidate: Force the page does not cache, the role and no-cache the same, but more stringent, mandatory means more obvious. Detailed role please refer to: http://hi.baidu.com/chenleibupt/blog/item/9627bec6932e5a179c163df2.html
About Post-check and pre-check:internet Explorer 5 use two new time interval instructions for HTTP header information: Pre-Check and Post-check. The Pre-Check extension defines such a time interval (in seconds): After this interval, an object should be selected for updating before it is displayed to the user. The selected object can also occur after the object has been displayed to the user, but make sure that the cached copy is updated the next time the user wants to see the object. The Post-check extension defines such a time interval (in seconds): After that time, the object is selected for updating before it is displayed to the user. That is, post-check=0,pre-check=0 is IE5.0 only to prevent cache statement. (Reference from http://bbs.chinaunix.net/thread-704320-1-1.html and http://blog.sina.com.cn/s/blog_5595d51401000b23.html)
About Pragma:no-cache, same with Cache-control:no-cache. Pragma:no-cache is compatible with HTTP 1.0, Cache-control:no-cache is provided by HTTP 1.1. Therefore, Pragma:no-cache can be applied to HTTP 1.0 and HTTP 1.1, while Cache-control:no-cache can only be applied to HTTP 1.1.
About the role of pragma:public unknown, please read this article of the heroes to give an explanation.