- 时间:2022-08-26 23:10 编辑: 来源: 阅读:305
- 扫一扫,手机访问
摘要:简单的Apache是可以改进的。
《互站网》
下面是如何用Apache提高简单性的一小部分。 本文收集了少量关于apache的简单性可以改进的信息;它演示了如何使用mod_expires、mod_deflate、mod_cache和mod_headers。 。htaccess或httpd.confHttpd.conf提供核心apache配置,而。htaccess提供了特定于目录的配置。 首选是使用httpd。 如果可能的话,因为使用htaccess将在每个请求的子目录中搜索htaccess。取决于你的主人,这个决定可以是你自己的。 mod_deflate mod_deflate告诉apache应该将服务器的响应用于压缩。 选项有:AddOutputFilterByType——使用此选项,必须使mod _ filter/mod _ filter。所以加载模块过滤器_模块板。AddOutputFilterByType shrink Text/html Text/XmlText/CSS Text/Plain Extension:SetOutputFilter DEFLATE如果使用AddOutputFilterByType,那么需要确保定义了mime类型。 其余说明:Deflate压缩级别-1到9-值越大,压缩越大,但是成本越高,CPU也可以使用mod_deflate日志文件的压缩比。 把它们放在一起:load module filter _ module modules/mod _ filter . so load module deflate _ modules/mod _ deflate . so # mime类型列表-addoutputfilterbytype deflate text/html text/XML text/plain addoutputfilterbytype deflate image/SVG+XML application/XHTML+XML application/XML addoutputfilterbytype deflate application/rdf+XML application/RSS+XML application+XML application+XML application+XML addoutputfilter bytype deflate text/JavaScript application/JavaScript application/x-Java不-gzip!gzip-only-text/html browser match \ bOpera!No-gzipmod_expires这个部分设置缓存控制的Expires HTTP头和HTTP头中的max-age。 格式为:ExpiresByType mime类型“访问+y年,M个月,D天,H小时”。典型的配置是:加载模块expires _ module modules/mod _ expires . so expires active on expires default " access plus 30 days " expires bytype image/jpg " access plus 30 days " expires bytype image/png " access plus 30 days " expires bytype image/gif " access plus 30 days " expires bytype image/JPEG " access plus 30 days " expires bytype text/CSS " access plus 1 days " expires bytype image/x-icon " access plus 30 days " expires bytype应用程序 x-wav“访问加30天”ExpiresByType audio/mpeg“访问加30天”ExpiresByType video/mpeg“访问加30天”ExpiresByType video/ mp4“访问加30天”ExpiresByType video/quicktime“访问加30天”ExpiresByType video/ x-ms-wmv“访问加30天”ExpiresByType application/x-shock wave-flash“访问加30天”ExpiresByType text/ javascript“访问加30天”ExpiresByType load module headers _ module modules/mod _ headers . so Header set Cache-Control " max-age = 2592000,Public " Header set Cache-Control " max-age = 604800,Public " Header set Cache-Control " max-age = 216000,private " Header set Cache-Control " max-age = 600,private,must-renew " Header unset last-modified detagetag是资源的唯一ID,在每台服务器上进行配置。 问题是,在一些集群环境中,您最终能否缓存相同的资源,因为它们有不同的ETags? 禁止ETag的决定应该基于环境,因为禁止它们将迫使浏览器依赖缓存控制和过期头。 禁止的语法是:load module headers _ module modules/mod _ headers . sofile tag none header unset tag。