diff --git a/src/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php b/src/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php index 3655fde742154..642907c127b8f 100644 --- a/src/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php +++ b/src/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php @@ -12,7 +12,7 @@ namespace Symfony\Bundle\AsseticBundle\Controller; use Assetic\Asset\AssetCache; -use Assetic\AssetManager; +use Assetic\Factory\LazyAssetManager; use Assetic\Cache\CacheInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -29,7 +29,7 @@ class AsseticController protected $am; protected $cache; - public function __construct(Request $request, AssetManager $am, CacheInterface $cache) + public function __construct(Request $request, LazyAssetManager $am, CacheInterface $cache) { $this->request = $request; $this->am = $am; @@ -43,18 +43,24 @@ public function render($name) } $asset = $this->getAsset($name); + $response = $this->createResponse(); - $response = new Response(); - - // validate if-modified-since + // 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 ($response->isNotModified($this->request)) { + return $response; } $response->setContent($asset->dump()); @@ -62,6 +68,11 @@ public function render($name) return $response; } + protected function createResponse() + { + return new Response(); + } + protected function getAsset($name) { return new AssetCache($this->am->get($name), $this->cache); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy