Merge branch 'dev' into 'dev'
Add modification date in Etag hash calculation and optimize cached photos processing See merge request hubzilla/core!1607
This commit is contained in:
commit
e937e8fff9
@ -95,7 +95,7 @@ class Photo extends \Zotlabs\Web\Controller {
|
|||||||
$default = $d['default'];
|
$default = $d['default'];
|
||||||
$data = $d['data'];
|
$data = $d['data'];
|
||||||
$mimetype = $d['mimetype'];
|
$mimetype = $d['mimetype'];
|
||||||
$modified = time();
|
$modified = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! $data) {
|
if(! $data) {
|
||||||
@ -162,18 +162,20 @@ class Photo extends \Zotlabs\Web\Controller {
|
|||||||
$allowed = (-1);
|
$allowed = (-1);
|
||||||
if($u === PHOTO_CACHE) {
|
if($u === PHOTO_CACHE) {
|
||||||
// Validate cache
|
// Validate cache
|
||||||
$cache = array(
|
if($cache_mode['on']) {
|
||||||
'resid' => $photo,
|
$cache = array(
|
||||||
'status' => false
|
'resid' => $photo,
|
||||||
);
|
'status' => false
|
||||||
if($cache_mode['on'])
|
);
|
||||||
call_hooks('cache_url_hook', $cache);
|
call_hooks('cache_url_hook', $cache);
|
||||||
if(! $cache['status']) {
|
if(! $cache['status']) {
|
||||||
$url = htmlspecialchars_decode($r[0]['display_path']);
|
$url = htmlspecialchars_decode($r[0]['display_path']);
|
||||||
if(strpos(z_root(),'https:') !== false && strpos($url,'https:') === false)
|
// SSLify if needed
|
||||||
$url = z_root() . '/sslify/' . $filename . '?f=&url=' . urlencode($url);
|
if(strpos(z_root(),'https:') !== false && strpos($url,'https:') === false)
|
||||||
header("Location: " . $url);
|
$url = z_root() . '/sslify/' . $filename . '?f=&url=' . urlencode($url);
|
||||||
killme();
|
header("Location: " . $url);
|
||||||
|
killme();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,10 +222,15 @@ class Photo extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
if(! $data)
|
if(! $data)
|
||||||
killme();
|
killme();
|
||||||
|
|
||||||
|
$etag = md5($data . $modified);
|
||||||
|
|
||||||
|
if($modified == 0)
|
||||||
|
$modified = time();
|
||||||
|
|
||||||
header_remove('Pragma');
|
header_remove('Pragma');
|
||||||
|
|
||||||
if($_SERVER['HTTP_IF_NONE_MATCH'] === md5($data) || $_SERVER['HTTP_IF_MODIFIED_SINCE'] === gmdate("D, d M Y H:i:s", $modified) . " GMT") {
|
if($_SERVER['HTTP_IF_NONE_MATCH'] === $etag || $_SERVER['HTTP_IF_MODIFIED_SINCE'] === gmdate("D, d M Y H:i:s", $modified) . " GMT") {
|
||||||
header_remove('Expires');
|
header_remove('Expires');
|
||||||
header_remove('Cache-Control');
|
header_remove('Cache-Control');
|
||||||
header_remove('Set-Cookie');
|
header_remove('Set-Cookie');
|
||||||
@ -272,7 +279,7 @@ class Photo extends \Zotlabs\Web\Controller {
|
|||||||
|
|
||||||
header("Content-type: " . $mimetype);
|
header("Content-type: " . $mimetype);
|
||||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $modified) . " GMT");
|
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $modified) . " GMT");
|
||||||
header("ETag: " . md5($data));
|
header("ETag: " . $etag);
|
||||||
header("Content-Length: " . (isset($filesize) ? $filesize : strlen($data)));
|
header("Content-Length: " . (isset($filesize) ? $filesize : strlen($data)));
|
||||||
|
|
||||||
// If it's a file resource, stream it.
|
// If it's a file resource, stream it.
|
||||||
|
Reference in New Issue
Block a user