Skip to content

Commit

Permalink
Remove cache age expiry
Browse files Browse the repository at this point in the history
Closes #2499.
  • Loading branch information
stickz committed May 1, 2023
1 parent 076a6c8 commit 551af5d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
10 changes: 2 additions & 8 deletions conf/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,8 @@

$localHostedMode = false; // Set to true if rTorrent is hosted on the SAME machine as ruTorrent

$cachedPluginLoading = false; // Set to true to enable rapid cached loading of ruTorrent plugins
$pluginJSCacheExpire = 3*60; // Sets duration ruTorrent plugin javascript cache is valid for in minutes
// Default is 3 hours which equals 3 hours * 60 minutes due to caching issues
// Optionally raise this value and clear web browser cache when upgrading versions

$miscCacheExpire = 3*60*24; // Sets duration ruTorrent miscellaneous web browser cache is valid for in minutes
// The goal here to avoid keeping stale content in the web browser
// Default is 3 days which equals 3 days * 60 minutes * 24 hours
$cachedPluginLoading = false; // Set to true to enable rapid cached loading of ruTorrent plugins
// Required to clear web browser cache when upgrading versions

$localhosts = array( // list of local interfaces
"127.0.0.1",
Expand Down
9 changes: 2 additions & 7 deletions php/getplugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,5 @@ function testRemoteRequests($remoteRequests)
}

global $cachedPluginLoading;
if ($cachedPluginLoading)
{
global $pluginJSCacheExpire;
CachedEcho::send($jResult,"application/javascript",true,true,$pluginJSCacheExpire);
}
else
CachedEcho::send($jResult,"application/javascript",false);
$cacheResults=(isset($cachedPluginLoading) && $cachedPluginLoading);
CachedEcho::send($jResult,"application/javascript",$cacheResults);
6 changes: 2 additions & 4 deletions php/utility/cachedecho.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@

class CachedEcho
{
public static function send( $content, $type = null, $cacheable = false, $exit = true, $cacheDuration = -1 )
public static function send( $content, $type = null, $cacheable = false, $exit = true )
{
header("X-Server-Timestamp: ".time());
if($cacheable && isset($_SERVER['REQUEST_METHOD']) && ($_SERVER['REQUEST_METHOD']=='GET'))
{
global $miscCacheExpire;
$cacheAge = ($cacheDuration == -1) ? $miscCacheExpire : $cacheDuration;
$etag = '"'.strtoupper(dechex(crc32($content))).'"';
header('Expires: ');
header('Pragma: ');
header('Cache-Control: max-age='.$cacheAge);
header('Cache-Control: ');
if(isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag)
{
header('HTTP/1.0 304 Not Modified');
Expand Down
2 changes: 1 addition & 1 deletion plugins/rss/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
$val = $mngr->get();
$errorsReported = true;
}
CachedEcho::send(JSON::safeEncode($val), "application/json",false,false);
CachedEcho::send(JSON::safeEncode($val), "application/json",true,false);

ob_flush();
flush();
Expand Down

0 comments on commit 551af5d

Please sign in to comment.