mirror of
https://github.com/mrclay/minify.git
synced 2025-08-15 02:24:13 +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() {
|
||||
$hash = $this->getHash();
|
||||
$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;
|
||||
}
|
||||
}
|
||||
$lastModified = $this->getLastModified();
|
||||
|
||||
$lastModifiedGMT = gmdate('D, d M Y H:i:s', $lastModified).' GMT';
|
||||
|
||||
@@ -359,6 +350,26 @@ class Minify {
|
||||
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
|
||||
* to be minified.
|
||||
@@ -381,7 +392,8 @@ class Minify {
|
||||
* @return bool|string
|
||||
*/
|
||||
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 ($return) {
|
||||
|
Reference in New Issue
Block a user