-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathcache.php
30 lines (25 loc) · 894 Bytes
/
cache.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
$seconds = 315360000; // 10 years
$now = $expires = time();
$filepath = $_GET[ "file" ];
$expires += $seconds;
if( eregi( "\.php", $filepath ) || eregi( "^http", $filepath ) )
die( "no found!" );
header( "Last-Modified: " . gmdate( 'D, d M Y H:i:s T', $now ) );
header( "Expires: " . gmdate( 'D, d M Y H:i:s T', $expires ) );
header( "Cache-Control: max-age=" . $seconds );
if( eregi( "\.css", $filepath ) )
header("Content-Type: text/css");
else if(eregi("\.js", $filepath))
header("Content-Type: text/javascript");
else if(eregi("\.gif", $filepath))
header("Content-Type: image/gif");
else if(eregi("\.jpg", $filepath))
header("Content-Type: image/jpeg");
if( eregi( "gzip", $_SERVER[ "HTTP_ACCEPT_ENCODING" ] ) !== false &&
is_file( $filepath . ".gz") ){
$filepath = $filepath . ".gz";
header( "Content-Encoding: gzip" );
}
readfile( $filepath );
?>