From e6918cd1bde0f547415d0e041ef793c54b5dc4b1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 1 Nov 2017 09:41:19 -0400 Subject: [PATCH] implement crude cache busting code for .js and .css files --- web/includes/functions.php | 14 +++++++++++++- web/skins/classic/includes/functions.php | 10 +++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/web/includes/functions.php b/web/includes/functions.php index 012dc7760..c84eab8ed 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -2060,6 +2060,18 @@ function detaintPath( $path ) { return( $path ); } +function cache_bust( $file ) { + # Use the last modified timestamp to create a link that gets a different filename + # To defeat caching. Should probably use md5 hash + $cacheFile = '/cache/'.basename($file).'-'.filemtime($file); + if ( file_exists( ZM_PATH_WEB.$cacheFile ) or symlink( ZM_PATH_WEB.'/'.$file, ZM_PATH_WEB.$cacheFile ) ) { + return $cacheFile; + } else { + Warning("Failed linking $file to $cacheFile"); + } + return $file; +} + function getSkinFile( $file ) { global $skinBase; $skinFile = false; @@ -2068,7 +2080,7 @@ function getSkinFile( $file ) { if ( file_exists( $tempSkinFile ) ) $skinFile = $tempSkinFile; } - return( $skinFile ); + return $skinFile; } function getSkinIncludes( $file, $includeBase=false, $asOverride=false ) { diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 26cb1a26e..c2b5a14de 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -60,11 +60,11 @@ if ( file_exists( "skins/$skin/css/$css/graphics/favicon.ico" ) ) { - + - + - + - + - +