From 5067a03c88896f818e1cc8e096e19384f1bc421b Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Fri, 9 Jan 2015 23:54:34 -0800 Subject: [PATCH] Use the etag in the internal AssetCache cache key The etag provides slightly more metadata about the asset due to the way the etag is constructed than the AssetCache does. This passes the etag along to the AssetCache as a HashableInterface AssetFilter, where the etag is considered the hash of the filter. --- Controller/AssetCacheKeyFilter.php | 50 ++++++++++++++++++++++++++++++ Controller/AsseticController.php | 4 ++- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 Controller/AssetCacheKeyFilter.php diff --git a/Controller/AssetCacheKeyFilter.php b/Controller/AssetCacheKeyFilter.php new file mode 100644 index 00000000..0ad13144 --- /dev/null +++ b/Controller/AssetCacheKeyFilter.php @@ -0,0 +1,50 @@ +cacheKey = $cacheKey; + } + + /** + * {@inheritdoc} + */ + public function hash() + { + return $this->cacheKey; + } + + public function filterLoad(AssetInterface $asset) + { + } + + public function filterDump(AssetInterface $asset) + { + } +} diff --git a/Controller/AsseticController.php b/Controller/AsseticController.php index c467ad9c..61d33342 100644 --- a/Controller/AsseticController.php +++ b/Controller/AsseticController.php @@ -86,7 +86,9 @@ public function render($name, $pos = null) return $response; } - $response->setContent($this->cachifyAsset($asset)->dump()); + $etagCacheKeyFilter = new AssetCacheKeyFilter($response->getEtag()); + + $response->setContent($this->cachifyAsset($asset)->dump($etagCacheKeyFilter)); return $response; }