Merge pull request #5338 from kurund/CRM-15756
[civicrm-core.git] / CRM / Core / Page / AJAX.php
index af7ae6613a403866019baf89d540ae0ae45fa45d..21adef2cefd486c6d9b94c2a2ae1196b9744d8f6 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -39,7 +39,7 @@
 class CRM_Core_Page_AJAX {
 
   /**
-   * Call generic ajax forms
+   * Call generic ajax forms.
    *
    */
   public static function run() {
@@ -89,7 +89,7 @@ class CRM_Core_Page_AJAX {
   }
 
   /**
-   * Change is_quick_config priceSet to complex
+   * Change is_quick_config priceSet to complex.
    *
    */
   public static function setIsQuickConfig() {
@@ -199,14 +199,19 @@ class CRM_Core_Page_AJAX {
   }
 
   /**
-   * Set headers appropriate for a js file
+   * Set headers appropriate for a js file.
+   *
+   * @param int|NULL $ttl
+   *   Time-to-live (seconds).
    */
-  public static function setJsHeaders() {
-    // Encourage browsers to cache for a long time - 1 year
-    $year = 60 * 60 * 24 * 364;
-    header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $year));
+  public static function setJsHeaders($ttl = NULL) {
+    if ($ttl === NULL) {
+      // Encourage browsers to cache for a long time - 1 year
+      $ttl = 60 * 60 * 24 * 364;
+    }
+    header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $ttl));
     header('Content-Type:      application/javascript');
-    header("Cache-Control: max-age=$year, public");
+    header("Cache-Control: max-age=$ttl, public");
   }
 
   /**
@@ -233,4 +238,5 @@ class CRM_Core_Page_AJAX {
     }
     CRM_Utils_System::civiExit();
   }
+
 }