I know this is an old topic but the only answers I could fine were the CompassElephantBundle and the above AsseticController hack. I've got an approach which is essentially but means I didn't have to edit the vendor package.
The way I have done it is to edit copy the original AsseticController and then linking to that in the config from the parameters.
parameters:
assetic.controller.class: Acme\RandomBundle\Controller\AsseticController
The copied AsseticController just does a preg_match for the filetype from the source path and corrects caching from there.
<?php
/* Original Assetic Controller */
public function render($name, $pos = null)
{
if (!$this->enableProfiler && null !== $this->profiler) {
$this->profiler->disable();
}
if (!$this->am->has($name)) {
throw new NotFoundHttpException(sprintf('The "%s" asset could not be found.', $name));
}
$asset = $this->am->get($name);
if (null !== $pos && !$asset = $this->findAssetLeaf($asset, $pos)) {
throw new NotFoundHttpException(sprintf('The "%s" asset does not include a leaf at position %d.', $name, $pos));
}
$bustCache = preg_match('/\.(scss|sass|less)$/', $asset->getSourcePath());
$response = $this->createResponse();
$response->setExpires(new \DateTime());
if ($bustCache) {
$lastModified = time();
$date = new \DateTime();
$date->setTimestamp($lastModified);
$response->setLastModified($date);
}
else
{
// last-modified
if (null !== $lastModified = $asset->getLastModified()) {
$date = new \DateTime();
$date->setTimestamp($lastModified);
$response->setLastModified($date);
}
}
// etag
if ($this->am->hasFormula($name)) {
$formula = $this->am->getFormula($name);
$formula['last_modified'] = $lastModified;
$response->setETag(md5(serialize($formula)));
}
if ($response->isNotModified($this->request)) {
return $response;
}
if ($bustCache) {
$response->setContent($asset->dump());
}
else {
$response->setContent($this->cachifyAsset($asset)->dump());
}
return $response;
}
/* Rest of controller */