mirror of
https://github.com/mrclay/minify.git
synced 2025-08-14 18:14:03 +02:00
Oops. It would probably be a good thing if caching actually worked.
This commit is contained in:
34
minify.php
34
minify.php
@@ -256,16 +256,7 @@ class Minify {
|
|||||||
*/
|
*/
|
||||||
public function browserCache() {
|
public function browserCache() {
|
||||||
$hash = $this->getHash();
|
$hash = $this->getHash();
|
||||||
$lastModified = 0;
|
$lastModified = $this->getLastModified();
|
||||||
|
|
||||||
// Get the timestamp of the most recently modified file.
|
|
||||||
foreach($this->files as $file) {
|
|
||||||
$modified = filemtime($file);
|
|
||||||
|
|
||||||
if ($modified !== false && $modified > $lastModified) {
|
|
||||||
$lastModified = $modified;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$lastModifiedGMT = gmdate('D, d M Y H:i:s', $lastModified).' GMT';
|
$lastModifiedGMT = gmdate('D, d M Y H:i:s', $lastModified).' GMT';
|
||||||
|
|
||||||
@@ -359,6 +350,26 @@ class Minify {
|
|||||||
return hash('md5', implode('', $this->files));
|
return hash('md5', implode('', $this->files));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the timestamp of the most recently modified file.
|
||||||
|
*
|
||||||
|
* @return int timestamp
|
||||||
|
*/
|
||||||
|
public function getLastModified() {
|
||||||
|
$lastModified = 0;
|
||||||
|
|
||||||
|
// Get the timestamp of the most recently modified file.
|
||||||
|
foreach($this->files as $file) {
|
||||||
|
$modified = filemtime($file);
|
||||||
|
|
||||||
|
if ($modified !== false && $modified > $lastModified) {
|
||||||
|
$lastModified = $modified;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lastModified;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified filename or array of filenames from the list of files
|
* Removes the specified filename or array of filenames from the list of files
|
||||||
* to be minified.
|
* to be minified.
|
||||||
@@ -381,7 +392,8 @@ class Minify {
|
|||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
public function serverCache($return = false) {
|
public function serverCache($return = false) {
|
||||||
$cacheFile = MINIFY_CACHE_DIR.'/minify_'.$hash;
|
$cacheFile = MINIFY_CACHE_DIR.'/minify_'.$this->getHash();
|
||||||
|
$lastModified = $this->getLastModified();
|
||||||
|
|
||||||
if (is_file($cacheFile) && $lastModified <= filemtime($cacheFile)) {
|
if (is_file($cacheFile) && $lastModified <= filemtime($cacheFile)) {
|
||||||
if ($return) {
|
if ($return) {
|
||||||
|
Reference in New Issue
Block a user