Created
July 11, 2012 19:54
-
-
Save brentjanderson/3092857 to your computer and use it in GitHub Desktop.
Yii Framework cache busting with Git and some magic page post-processing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function processOutput($output) { | |
$output = parent::processOutput($output); | |
$output = str_replace('.css', '.css?' . Yii::app()->params['git-hash'], $output); | |
$output = str_replace('.js', '.js?' . Yii::app()->params['git-hash'], $output); | |
return $output; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$output = array(); | |
$gitHash = exec('git rev-parse --verify HEAD 2> /dev/null', $output); // Thanks to AD7six (http://stackoverflow.com/a/9193040/704939) | |
$gitHash = $output[0]; | |
return array( | |
/* All your configuration settings down to params */ | |
'params' => array( | |
'git-hash' => $gitHash, | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment