I’d like to know what people who use external asset build tools (grunt etc. rather than Asset Manager) do for cache-busting. To start the discussion, here’s my new scheme. It’s not very DRY but it should work.
[*]Grunt builds js and css files.
The web server sets a distant Expires value for ".js" and "*.css" files.
[*]In app root, a file "constants.php" contains YII_DEBUG etc. that the entry scripts include.
[*]“constants.php” also declares my app’s CACHE_BUSTER global const.
[*]When grunt runs, it updates “constants.php” changing the value of CACHE_BUSTER to the current git short hash, e.g. [font=“Courier New”]define(‘CACHE_BUSTER’, ‘8a522dc’)[/font].
[*]Grunt uses the same value in the name of the asset files it makes, e.g. "script.8a522dc.js".
[*]The layout views use CACHE_BUSTER in the URLs to the static files, e.g. "/js/script.8a522dc.js".
What does everyone else do? Do you have a critique of this plan?
And is there anything Yii could do to be more helpful in solving this problem?