[英]Django-AWS gzip compression not enabled?
我遵循了本教程: https : //realpython.com/blog/python/deploying-a-django-app-to-aws-elastic-beanstalk/將我的Django站點部署到AWS。 一切正常,但是當我使用Google的PageSpeed時,它告訴我未啟用gzip。 這是兩個文件:
03_apache.config
container_commands:
01_setup_apache:
command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
enable_mod_deflate.conf
# mod_deflate configuration
<IfModule mod_deflate.c>
# Restrict compression to these MIME types
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xml+rss
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
# Level of compression (Highest 9 - Lowest 1)
DeflateCompressionLevel 9
# Netscape 4.x has some problems.
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
<IfModule mod_headers.c>
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
這些文件位於.ebextensions中,應該能夠設置gzip。 我究竟做錯了什么?
嘗試使用NGINX代替Apache。 Nginx在Apache之后問世,對並發問題有更多的了解,這些並發問題將在大規模站點上出現。 利用這些知識,Nginx從頭開始設計為使用異步,非阻塞,事件驅動的連接處理算法。
NGINX Configuration比Apache更易於使用。
對於gzip壓縮,請點擊此鏈接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.