Recently I was working with Assetic for combining and minifying CSS and JS files but ran into an issue with regards to caching the created asset collection. The resulting minified file was being rewritten on every page load which was no good at all.
TL;DR: Get the asset collection’s “last modified” property and compare it to the written minified file to determine if it needs updating.
Updated Feb 29, 2016
This post originally used String Assets to cache the collection’s content. It
was later found that the string asset caches would conflict due to string assets
not having “source” or “target” paths which are a component of the hash. Though
an arbitrary source could be set on a string asset to resolve the issue, it’s
probably better to just use the collection’s getLastModified before writing
the minified file. The post has been updated to reflect the new approach.