Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Nov 22, 2017
1 parent 4f27291 commit 78e25dd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions example/dist/loader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

if (!isset($_GET['file'])) {
exit();
}

header("Content-type: text/css");

$lastModified_unix = filemtime($_GET['file']);
$lastModified = gmdate("D, d M Y H:i:s \G\M\T", $lastModified_unix);
$ifModifiedSince = false;

if (isset($_ENV['HTTP_IF_MODIFIED_SINCE'])) {
$ifModifiedSince = strtotime(substr($_ENV['HTTP_IF_MODIFIED_SINCE'], 5));
}

if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
$ifModifiedSince = strtotime(substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 5));
}

if ($ifModifiedSince && $ifModifiedSince >= $lastModified_unix) {
header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
exit;
}

if (isset($_GET['sleep'])) {
sleep($_GET['sleep']);
}

header('Last-Modified: '. $lastModified);

echo file_get_contents($_GET['file']);

0 comments on commit 78e25dd

Please sign in to comment.