Skip to content
Browse files

cache /js/ for 10 days rather than none. Refs #2406

  • Loading branch information...
1 parent 91f7578 commit c1703a107774db816b5a65717ee1d9de394cffa4 @mattab mattab committed Mar 10, 2014
Showing with 7 additions and 7 deletions.
  1. +5 −5 core/ProxyHttp.php
  2. +2 −2 js/index.php
View
10 core/ProxyHttp.php
@@ -51,10 +51,10 @@ public static function isHttps()
*
* @param string $file The location of the static file to serve
* @param string $contentType The content type of the static file.
- * @param bool $expireFarFuture If set to true, will set Expires: header in far future.
- * Should be set to false for files that don't have a cache buster (eg. piwik.js)
+ * @param bool $expireFarFuture Day in the far future to set the Expires header to.
+ * Should be set to false for files that don't have a cache buster (eg. piwik.js)
*/
- public static function serverStaticFile($file, $contentType, $expireFarFuture = true)
+ public static function serverStaticFile($file, $contentType, $expireFarFutureDays = 100)
{
if (file_exists($file)) {
// conditional GET
@@ -76,9 +76,9 @@ public static function serverStaticFile($file, $contentType, $expireFarFuture =
@header('Vary: Accept-Encoding');
@header('Content-Disposition: inline; filename=' . basename($file));
- if ($expireFarFuture) {
+ if ($expireFarFutureDays) {
// Required by proxy caches potentially in between the browser and server to cache the request indeed
- @header("Expires: " . gmdate('D, d M Y H:i:s', time() + 86400 * 100) . ' GMT');
+ @header("Expires: " . gmdate('D, d M Y H:i:s', time() + 86400 * (int)$expireFarFutureDays) . ' GMT');
}
// Returns 304 if not modified since
View
4 js/index.php
@@ -30,7 +30,7 @@
$file = '../piwik.js';
// There is no cache buster parameter so we don't set Expires: header
-$expireFarFuture = false;
-ProxyHttp::serverStaticFile($file, "application/javascript; charset=UTF-8", $expireFarFuture);
+$daysExpireFarFuture = 10;
+ProxyHttp::serverStaticFile($file, "application/javascript; charset=UTF-8", $daysExpireFarFuture);
exit;

0 comments on commit c1703a1

Please sign in to comment.
Something went wrong with that request. Please try again.