A free, self-hostable news aggregator…
Serve HTTP cache for default favicon + better headers
Marien Fressinaudf5043dbf719d
diff --git a/p/f.php b/p/f.phpindex 411f65081..c904e1fcb 100644--- a/p/f.php+++ b/p/f.php@@ -4,6 +4,7 @@ require('../constants.php');include(LIB_PATH . '/Favicon/Favicon.php');include(LIB_PATH . '/Favicon/DataAccess.php');+require(LIB_PATH . '/http-conditional.php');$favicons_dir = DATA_PATH . '/favicons/';@@ -46,9 +47,13 @@ function download_favicon($website, $dest) {function show_default_favicon() {global $default_favicon;- header('Content-Type: image/ico');- readfile($default_favicon);- die();+ header('Content-Type: image/x-icon');+ header('Content-Disposition: inline; filename="default_favicon.ico"');++ $default_mtime = @filemtime($default_favicon);+ if (!httpConditional($default_mtime, 2592000, 2)) {+ readfile($default_favicon);+ }}@@ -63,19 +68,22 @@ $ico = $favicons_dir . $id . '.ico';$ico_mtime = @filemtime($ico);$txt_mtime = @filemtime($txt);-if (($ico_mtime == false) || ($txt_mtime > $ico_mtime)) {++if ($ico_mtime == false || $txt_mtime > $ico_mtime) {if ($txt_mtime == false) {show_default_favicon();+ return;}+ // no ico file or we should download a new one.$url = file_get_contents($txt);if (!download_favicon($url, $ico)) {+ // Download failed, show the default faviconshow_default_favicon();+ return;}}-require(LIB_PATH . '/http-conditional.php');-header('Content-Type: image/x-icon');header('Content-Disposition: inline; filename="' . $id . '.ico"');