Asset manager

Just came across this … Could we have b64’ed hashes in Yii 2 for the assets instead of hexstrings? They tend to be much more compact.

For CSS caching, we have been using this, successfully:


<?php echo CHtml::cssFile( '/css/main.css?' . filemtime( 'css/main.css' ) ); ?>

Recently I was thinking hard about how to do what the HTML5 Boilerplate Build Script does in a Yii app.

This stuff is really important, especially for mobile.

In Yii 1.1 it is not easy. I don’t know what the right design is but I have some thoughts.

Content is much better than file name and mtime for versioning.

There’s a design trade off to be made when combining css/js files. We want to maximize the use of caches and minimize the number of requests. If your Yii app’s pages all have different combinations of assets but many of the assets are used on multiple pages then combining all assets on a page-by-page basis is a very poor use of caches and bandwidth. So I think the strategy for combining needs to be under the control of the programmer. Perhaps Yii 1.1’s CClientScript::$packages is a suitable basis for combinations.

Which reminds me, is Yii2 retaining the separation of CClientScript and CAssetManager? I often feel life would be easier if these were integrated.