Skip to content

Instantly share code, notes, and snippets.

@wokamoto
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wokamoto/9066721 to your computer and use it in GitHub Desktop.
Save wokamoto/9066721 to your computer and use it in GitHub Desktop.
<?php
$mime_type = 'application/pdf';
$file_path = '/path/to/pdf';
// for IE 8 ( see http://support.microsoft.com/kb/323308/ja )
$expires = 30;
header("Last-Modified: ". gmdate("D, d M Y H:i:s", filemtime($file_path)). " GMT");
header("Expires: " . date(DATE_RFC1123, time() + $expires));
header("Pragma: cache");
header("Cache-Control: max-age={$expires}");
header("Cache-Control: cache");
// for IE 8
header('Content-Disposition: inline; filename="'.basename($file_path).'"');
header('Content-Length: '.filesize($file_path));
header('Content-Type: '.$mime_type);
readfile($file_path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment