This is a convenience method for common use of the class
public static check ( integer $lastModifiedTime = null, boolean $isPublic = false, array $options = [] ) | ||
$lastModifiedTime | integer | if given, both ETag AND Last-Modified headers will be sent with content. This is recommended. |
$isPublic | boolean | (default false) if true, the Cache-Control header will contain "public", allowing proxies to cache the content. Otherwise "private" will be sent, allowing only browser caching. |
$options | array | (default empty) additional options for constructor |
public static function render($arrFilter) { $dtLastModified = 0; //*** Load sources from sources directory. if (is_dir($GLOBALS["_PATHS"]['css'])) { //*** Directory exists. foreach ($arrFilter as $strFilter) { $strFile = $GLOBALS["_PATHS"]['css'] . "{$strFilter}.css"; $dtLastModified = self::getLastModified($strFile, $dtLastModified); //*** Auto check custom files. if (strpos($strFilter, "-custom") === false) { $strFile = $GLOBALS["_PATHS"]['css'] . "{$strFilter}-custom.css"; $dtLastModified = self::getLastModified($strFile, $dtLastModified); } } } //*** Check if we can send a "Not Modified" header. \HTTP_ConditionalGet::check($dtLastModified, true, array("maxAge" => 1200000)); //*** Modified. Get contents. $strOutput = self::minify($arrFilter); //*** Gzip the CSS. $objEncoder = new \HTTP_Encoder(array("content" => $strOutput, "type" => "text/css")); $objEncoder->encode(); $objEncoder->sendAll(); }
public static function render($arrFilter) { $dtLastModified = 0; //*** Load sources from sources directory. if (is_dir($GLOBALS["_PATHS"]['js'])) { //*** Directory exists. foreach ($arrFilter as $strFilter) { $strFile = $GLOBALS["_PATHS"]['js'] . $strFilter . ".js"; if (is_file($strFile)) { $lngLastModified = filemtime($strFile); if (empty($dtLastModified) || $lngLastModified > $dtLastModified) { $dtLastModified = $lngLastModified; } } } } //*** Check if we can send a "Not Modified" header. \HTTP_ConditionalGet::check($dtLastModified, true, array("maxAge" => 1200000)); //*** Modified. Get contents. $strOutput = self::minify($arrFilter); //*** Gzip the Javascript. $objEncoder = new \HTTP_Encoder(array("content" => $strOutput, "type" => "text/javascript")); $objEncoder->encode(); $objEncoder->sendAll(); }