File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,7 +164,11 @@ protected function fromCache(MvcEvent $e, $match)
164164 $ response = $ e ->getResponse ();
165165
166166 if (($ result = $ cache ->getItem ($ key ))) {
167- $ response ->setContent ($ result );
167+ $ response ->setContent (
168+ empty ($ this ->serviceLocator ->get ('Config ' )['slm_cache ' ]['use_compression ' ])
169+ ? $ result
170+ : gzuncompress ($ result )
171+ );
168172 $ response ->getHeaders ()->addHeaderLine ('X-Slm-Cache ' , 'Fetch: Hit; route= ' . $ match ['route ' ]);
169173 $ e ->setParam ('cached ' , true );
170174
@@ -181,6 +185,11 @@ protected function storeCache(MvcEvent $e, $match)
181185
182186 $ response = $ e ->getResponse ();
183187 $ response ->getHeaders ()->addHeaderLine ('X-Slm-Cache ' , 'Storage: Success; route= ' . $ match ['route ' ]);
188+
189+ if (!empty ($ this ->serviceLocator ->get ('Config ' )['slm_cache ' ]['use_compression ' ])) {
190+ return $ cache ->setItem ($ key , gzcompress ($ response ->getContent ()));
191+ }
192+
184193 $ cache ->setItem ($ key , $ response ->getContent ());
185194 }
186195
You can’t perform that action at this time.
0 commit comments