0
A
回答
1
您可以通過在index.php中的yii \ web \ Response上附加事件處理程序來使其工作。
$application = new yii\web\Application($config);
$application->on(yii\web\Application::EVENT_BEFORE_REQUEST, function(yii\base\Event $event){
$event->sender->response->on(yii\web\Response::EVENT_BEFORE_SEND, function($e){
ob_start("ob_gzhandler");
});
$event->sender->response->on(yii\web\Response::EVENT_AFTER_SEND, function($e){
ob_end_flush();
});
});
$application->run();
0
我添加了以下規則爲.htaccess:
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/opentype" \
"image/bmp" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
相關問題
- 1. 如何在Yii2中啓用gzip壓縮
- 2. 如何爲Jetty 9啓用GZIP
- 3. 如何爲favicon.ico啓用gzip壓縮?
- 4. 爲Jboss啓用gzip壓縮
- 5. AFNetworking啓用GZIP
- 6. Nginx啓用gzip
- 7. 啓用JIRA GZIP
- 8. 如何在Vapor應用中啓用GZip?
- 9. 如何使用gSOAP啓用GZIP?
- 10. 如何在Dreamhost上啓用gzip?
- 11. 啓用yii2
- 12. 啓用gzip壓縮
- 13. 啓用GZIP壓縮
- 14. 啓用gzip壓縮
- 15. 如何爲使用Tomcat的Spring HttpInvoker請求啓用GZIP壓縮?
- 16. 如何在AWS EC2 Server中爲spring引導項目啓用gzip?
- 17. RESTEasy啓用GZIP支持?
- 18. RestEasy的普遍啓用Gzip
- 19. 在CakePHP2中啓用GZIP +
- 20. WordPresspress:啓用GZIP壓縮
- 21. S3 +的CloudFlare啓用gzip
- 22. PHP啓用壓縮中GZIP
- 23. 如何使用GZIP?
- 24. 如何使用gzip
- 25. 如何使用Yii2多語言行爲
- 26. 如何使用yii2
- 27. 使用MVC3啓用gzip壓縮
- 28. 啓用GZIP是GWT應用程序
- 29. 1and1 - 啓用gzip壓縮不起作用
- 30. 使用fetch.js啓用gzip壓縮