This sounds like a job for a Dispatcher Filter [http://book.cakephp.org/2.0/en/development/dispatch-filters.html]
-- You could write a DispatcherFilter that changes the content of $response->body on the afterDispatch event.
I've not had any first hand experience with DispatcherFilters, but this seems like the right place to do it.
However, you might get better mileage from adding a compressor to your web server (mod_deflate for Apache, gzip module for Nginx).
Regards
Reuben Helms
On Tuesday, 10 June 2014 22:16:08 UTC+10, Сергей Калистратов wrote:
On Tuesday, 10 June 2014 22:16:08 UTC+10, Сергей Калистратов wrote:
I want to compress the output of the entire HTML codeI have simple functionpublic function sanitize_output($buffer) {$search = array('/\>[^\S ]+/s', // strip whitespaces after tags, except space'/[^\S ]+\</s', // strip whitespaces before tags, except space'/(\s)+/s' // shorten multiple whitespace sequences);$replace = array('>','<','\\1');$buffer = preg_replace($search, $replace, $buffer);return $buffer;}I found that the output of all content located in renderLayout.How can I override and before displaying content use my function? Or is there still what that means for compression of the whole page?Thank you very much!
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment