diff options
| author | 2016-04-23 21:48:37 +0200 | |
|---|---|---|
| committer | 2016-04-23 21:48:37 +0200 | |
| commit | 624824673592dbc21300f9a26c27781f54429de5 (patch) | |
| tree | c084c2aa6c07223bfe241e531dbfdfe82d8d98c9 /p/f.php | |
| parent | f3696784ea0acd15a11a4ca193abe623fd77dc33 (diff) | |
Adjust caching for favicon with errors
Diffstat (limited to 'p/f.php')
| -rw-r--r-- | p/f.php | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -44,14 +44,13 @@ function download_favicon($website, $dest) { } -function show_default_favicon() { +function show_default_favicon($cacheSeconds = 3600) { global $default_favicon; - 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)) { + if (!httpConditional($default_mtime, $cacheSeconds, 2)) { readfile($default_favicon); } } @@ -68,10 +67,11 @@ $ico = $favicons_dir . $id . '.ico'; $ico_mtime = @filemtime($ico); $txt_mtime = @filemtime($txt); +header('Content-Type: image/x-icon'); if ($ico_mtime == false || $txt_mtime > $ico_mtime) { if ($txt_mtime == false) { - show_default_favicon(); + show_default_favicon(1800); return; } @@ -79,12 +79,11 @@ if ($ico_mtime == false || $txt_mtime > $ico_mtime) { $url = file_get_contents($txt); if (!download_favicon($url, $ico)) { // Download failed, show the default favicon - show_default_favicon(); + show_default_favicon(86400); return; } } -header('Content-Type: image/x-icon'); header('Content-Disposition: inline; filename="' . $id . '.ico"'); if (!httpConditional($ico_mtime, 2592000, 2)) { |
