From da7d34d2ef45e4cfcf1410a279998f680a6338ea Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 26 Jan 2015 13:02:47 +0100 Subject: Default favicon served with HTTP code 200 Fix https://github.com/FreshRSS/FreshRSS/issues/760 --- p/f.php | 1 - 1 file changed, 1 deletion(-) (limited to 'p/f.php') diff --git a/p/f.php b/p/f.php index fefbf9a10..411f65081 100644 --- a/p/f.php +++ b/p/f.php @@ -46,7 +46,6 @@ function download_favicon($website, $dest) { function show_default_favicon() { global $default_favicon; - header('HTTP/1.1 404 Not Found'); header('Content-Type: image/ico'); readfile($default_favicon); die(); -- cgit v1.2.3 From f5043dbf719df913c7600be12528c0355b48fce7 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Mon, 26 Jan 2015 14:49:24 +0100 Subject: Serve HTTP cache for default favicon + better headers See https://github.com/FreshRSS/FreshRSS/commit/da7d34d2ef45e4cfcf1410a279998f680a6338ea#commitcomment-9439610 --- p/f.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'p/f.php') diff --git a/p/f.php b/p/f.php index 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 favicon show_default_favicon(); + return; } } -require(LIB_PATH . '/http-conditional.php'); - header('Content-Type: image/x-icon'); header('Content-Disposition: inline; filename="' . $id . '.ico"'); -- cgit v1.2.3