summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-08-14 09:58:40 +0300
committerAndrew Dolgov <[email protected]>2019-08-14 09:58:40 +0300
commite7edaca4dbae01521d2aada95af229ea3104845a (patch)
tree5f7065edd0af048b5669eb7e6cdcf1860e240f01 /plugins
parent3c075bfd21adac9a4dde4fab6bd22886d6173d30 (diff)
af_zz_imgproxy: redirect to cached_url if cache already exists so that urls are a bit shorter
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/af_zz_imgproxy/init.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/plugins/af_zz_imgproxy/init.php b/plugins/af_zz_imgproxy/init.php
index b1281dff0..754de12e1 100755
--- a/plugins/af_zz_imgproxy/init.php
+++ b/plugins/af_zz_imgproxy/init.php
@@ -57,7 +57,9 @@ class Af_Zz_ImgProxy extends Plugin {
$local_filename = sha1($url);
if ($this->cache->exists($local_filename)) {
- $this->cache->send($local_filename);
+ header("Location: " . $this->cache->getUrl($local_filename));
+ return;
+ //$this->cache->send($local_filename);
} else {
$data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]);
@@ -67,8 +69,8 @@ class Af_Zz_ImgProxy extends Plugin {
if (!$disable_cache && strlen($data) > MIN_CACHE_FILE_SIZE) {
if ($this->cache->put($local_filename, $data)) {
- $mimetype = $this->cache->getMimeType($local_filename);
- header("Content-type: $mimetype");
+ header("Location: " . $this->cache->getUrl($local_filename));
+ return;
}
}
@@ -136,8 +138,11 @@ class Af_Zz_ImgProxy extends Plugin {
}
}
- return get_self_url_prefix() . "/public.php?op=pluginhandler&plugin=af_zz_imgproxy&pmethod=imgproxy&url=" .
- urlencode($url);
+ /* we don't need to handle URLs where local cache already exists, tt-rss rewrites those automatically */
+ if (!$this->cache->exists(sha1($url))) {
+ return get_self_url_prefix() . "/public.php?op=pluginhandler&plugin=af_zz_imgproxy&pmethod=imgproxy&url=" .
+ urlencode($url);
+ }
}
}