helpdesk #3799: download.php should allow caching of XML mirror lists.
Change-Id: Ic204ba2c656e67ccb24bb910f0038f79a9262733
Signed-off-by: Christopher Guindon <chris.guindon@eclipse-foundation.org>
diff --git a/download.php b/download.php
index 6dfddd2..c15379e 100755
--- a/download.php
+++ b/download.php
@@ -23,7 +23,6 @@
$Nav = new Nav();
$Menu = new Menu();
$Paypal = new Paypal();
- $App->preventCaching();
include("_projectCommon.php");
@@ -67,15 +66,11 @@
$pageTitle = "Eclipse downloads - Select a mirror";
$pageKeywords = "";
$pageAuthor = "Denis Roy";
- header("Cache-control: no-cache");
require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection_rw.class.php";
require_once "/home/data/httpd/eclipse-php-classes/system/dbconnection.class.php";
require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/classes/mirrors/mirror.class.php");
- # Initiate session
- $Session = $App->useSession("optional");
- $Friend = $Session->getFriend();
$Mirror = new Mirror();
$archiveBasePath = "/home/data2/httpd/archive.eclipse.org";
@@ -86,6 +81,21 @@
$_file = $App->getHTTPParameter("file");
$_file_id = $App->getHTTPParameter("file_id"); # Committers-only fast download
+ if ($_format !== 'xml') {
+ header("Cache-control: no-cache");
+ # Initiate session
+ $App->preventCaching();
+ $Session = $App->useSession("optional");
+ $Friend = $Session->getFriend();
+ }
+ else {
+ // Set cache lifetime to 5 minutes (300 seconds)
+ $cache_lifetime = 300;
+ // Send cache headers
+ header("Cache-Control: max-age={$cache_lifetime}, public, must-revalidate");
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cache_lifetime) . ' GMT');
+ }
+
//Bug 475734 - download.php should not offer to serve *.php content
$info = new SplFileInfo($_file);
if (strtolower($info->getExtension()) == 'php') {
@@ -448,7 +458,7 @@
# Bypass the whole mirror SQL if we can't pick a mirror for this file
$rs;
- if(!$no_mirror && $_mirror_id != 1 && $_mirror_id != 2) { #mirror_id 1 is download, 2 is friends
+ if(!$no_mirror && $_mirror_id != 1) { #mirror_id 1 is download
$rs = mysql_query($mirrorListSQL, $dbh);
$myrow = mysql_fetch_assoc($rs);
mysql_data_seek ($rs, 0);
@@ -459,11 +469,6 @@
}
else {
$_url = $app->getPubDownloadServerUrl() . $_file;
- if($_mirror_id == 2) {
- # Friends
- $_url = preg_replace('/http:\/\/download.eclipse.org/', 'https://friends.eclipse.org/downloads', $_url);
- }
-
# Bug 470444 - download of ZIP archives doesn't work anymore
$_redirect = 1;
}