瀏覽代碼

Remove some preload / prefetch (#2040)

* Remove next prefetch

This approach was only efficient in the specific case when no change was
made (no mark-as-read, favourites, tags), and useless in the other
situations.
Removed to reduce server load.

* Remove next prefetch from JavaScript too

* Remove some preload / prefetch

While useful for the first request, those preload / prefetch hints are
slightly negative for the following requets, especially server-side,
e.g. generating one log entry in Apache, and a bit more network traffic.

* Revert mistake

* Remove comment

https://github.com/FreshRSS/FreshRSS/pull/2040#discussion_r223214915
Alexandre Alapetite 7 年之前
父節點
當前提交
1cc891be35
共有 3 個文件被更改,包括 1 次插入20 次删除
  1. 0 1
      app/FreshRSS.php
  2. 1 12
      app/layout/layout.phtml
  3. 0 7
      p/scripts/main.js

+ 0 - 1
app/FreshRSS.php

@@ -90,7 +90,6 @@ class FreshRSS extends Minz_FrontController {
 				}
 				$filetime = @filemtime(PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename);
 				$url = '/themes/' . $theme_id . '/' . $filename . '?' . $filetime;
-				header('Link: <' . Minz_Url::display($url, '', 'root') . '>;rel=preload', false);	//HTTP2
 				Minz_View::prependStyle(Minz_Url::display($url));
 			}
 		}

+ 1 - 12
app/layout/layout.phtml

@@ -11,10 +11,6 @@
 		<?php echo self::headScript(); ?>
 		<link rel="shortcut icon" id="favicon" type="image/x-icon" sizes="16x16 64x64" href="<?php echo Minz_Url::display('/favicon.ico'); ?>" />
 		<link rel="icon msapplication-TileImage apple-touch-icon" type="image/png" sizes="256x256" href="<?php echo Minz_Url::display('/themes/icons/favicon-256.png'); ?>" />
-		<link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('starred', true); ?>" />
-		<link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('non-starred', true); ?>" />
-		<link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('read', true); ?>" />
-		<link rel="prefetch" href="<?php echo FreshRSS_Themes::icon('unread', true); ?>" />
 		<link rel="apple-touch-icon" href="<?php echo Minz_Url::display('/themes/icons/apple-touch-icon.png'); ?>" />
 		<meta name="apple-mobile-web-app-capable" content="yes" />
 		<meta name="apple-mobile-web-app-status-bar-style" content="black" />
@@ -32,14 +28,7 @@
 		<?php echo self::headTitle(); ?>
 <?php
 	$url_base = Minz_Request::currentRequest();
-	if (FreshRSS_Context::$next_id !== '') {
-		$url_next = $url_base;
-		$url_next['params']['next'] = FreshRSS_Context::$next_id;
-		$url_next['params']['ajax'] = 1;
-?>
-		<link id="prefetch" rel="next prefetch" href="<?php echo Minz_Url::display($url_next); ?>" />
-<?php
-	} if (isset($this->rss_title)) {
+	if (isset($this->rss_title)) {
 		$url_rss = $url_base;
 		$url_rss['a'] = 'rss';
 		if (FreshRSS_Context::$user_conf->since_hours_posts_per_rss) {

+ 0 - 7
p/scripts/main.js

@@ -1170,7 +1170,6 @@ freshrssLoadMoreEvent.initEvent('freshrss:load-more', true, true);
 
 function init_load_more(box) {
 	box_load_more = box;
-
 	document.body.dispatchEvent(freshrssLoadMoreEvent);
 
 	var $next_link = $("#load_more");
@@ -1181,12 +1180,6 @@ function init_load_more(box) {
 	}
 
 	url_load_more = $next_link.attr("href");
-	var $prefetch = $('#prefetch');
-	if ($prefetch.attr('href') !== url_load_more) {
-		$prefetch.attr('rel', 'next');	//Remove prefetch
-		$.ajax({url: url_load_more, ifModified: true });	//TODO: Try to find a less agressive solution
-		$prefetch.attr('href', url_load_more);
-	}
 
 	$next_link.click(function () {
 		load_more_posts();