incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vik...@apache.org
Subject svn commit: r1347305 - in /incubator/ambari/branches/ambari-186: CHANGES.txt hmc/fileCombinator.php
Date Thu, 07 Jun 2012 02:19:36 GMT
Author: vikram
Date: Thu Jun  7 02:19:36 2012
New Revision: 1347305

URL: http://svn.apache.org/viewvc?rev=1347305&view=rev
Log:
AMBARI-483. Start Making Responses From fileCombinator.php Suitably Cacheable (Contributed
by Varun)

Modified:
    incubator/ambari/branches/ambari-186/CHANGES.txt
    incubator/ambari/branches/ambari-186/hmc/fileCombinator.php

Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1347305&r1=1347304&r2=1347305&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Thu Jun  7 02:19:36 2012
@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-483. Start Making Responses From fileCombinator.php Suitably Cacheable (Varun via
Vikram)
+
   AMBARI-482. Show the same welcome page to the user if the user starts configuring a cluster
but has not started deploy yet (Yusaku via Vikram)
 
   AMBARI-481. Units of various config values not displayed on review and deploy page (Yusaku
via Vikram)

Modified: incubator/ambari/branches/ambari-186/hmc/fileCombinator.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/fileCombinator.php?rev=1347305&r1=1347304&r2=1347305&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/fileCombinator.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/fileCombinator.php Thu Jun  7 02:19:36 2012
@@ -23,6 +23,7 @@ $filesToLoad = explode('&', $_SERVER['QU
 
 $contentType = '';
 $responseBody = '';
+$servingYuiFile = false;
 
 foreach ($filesToLoad as $fileToLoad) 
 {
@@ -32,6 +33,11 @@ foreach ($filesToLoad as $fileToLoad) 
   if (empty($contentType))
   {
     $contentType = deduceContentType($fileToLoad);
+
+    if (preg_match('/^yui/', $fileToLoad))
+    {
+      $servingYuiFile = true;
+    }
   }
 
   $fileContents = file_get_contents('./' . $fileToLoad);
@@ -43,9 +49,15 @@ foreach ($filesToLoad as $fileToLoad) 
 }
 
 header('Content-type: ' . $contentType);
-/* TODO XXX Add appropriate Cache-Control/Age/Last-Modified/Expires headers 
- * here to be super-efficient. 
- */
+header('Content-Length: ' . strlen($responseBody));
+
+/* When we serve YUI files, make sure they're cached for a long time. */
+if( $servingYuiFile )
+{
+  $validitySecs = 24 * 60 * 60; /* 1 day */
+
+  header('Cache-Control: max-age=' . $validitySecs . ', must-revalidate, public');
+}
 
 echo $responseBody;
 



Mime
View raw message