Merge branch 'develop' of https://github.com/getgrav/grav into develop

This commit is contained in:
Andy Miller
2016-07-11 13:20:01 -06:00
2 changed files with 25 additions and 1 deletions

View File

@@ -29,7 +29,9 @@ class User extends Data
*/
public static function load($username)
{
$locator = Grav::instance()['locator'];
$grav = Grav::instance();
$locator = $grav['locator'];
$config = $grav['config'];
// force lowercase of username
$username = strtolower($username);
@@ -48,6 +50,9 @@ class User extends Data
$user = new User($content, $blueprint);
$user->file($file);
// add user to config
$config->set("user", $user);
return $user;
}

View File

@@ -270,6 +270,25 @@ abstract class Utils
} else {
$new_length = $size;
header("Content-Length: " . $size);
if (Grav::instance()['config']->get('system.cache.enabled')) {
$expires = Grav::instance()['config']->get('system.pages.expires');
if ($expires > 0) {
$expires_date = gmdate('D, d M Y H:i:s T', time() + $expires);
header('Cache-Control: max-age=' . $expires);
header('Expires: ' . $expires_date);
header('Pragma: cache');
}
header('Last-Modified: ' . gmdate("D, d M Y H:i:s T", filemtime($file)));
// Return 304 Not Modified if the file is already cached in the browser
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= filemtime($file))
{
header('HTTP/1.1 304 Not Modified');
exit();
}
}
}
/* output the file itself */