• apache配置httpd.conf相关


    1.apache开启压缩AddOutputFilterByType

    找到并打开apache/conf目录中的httpd.conf文件

    在httpd.conf中打开deflate_Module,headers_Module,filter_module模块,具体做法为将 如下两句前面的#去掉:
    LoadModule filter_module modules/mod_filter.so
    LoadModule deflate_module modules/mod_deflate.so
    LoadModule headers_module modules/mod_headers.so

    在httpd.conf文件底部加入如下代码配置需要压缩的文件:
    <IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/php
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilter DEFLATE js css
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/atom_xml
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/x-httpd-php
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/gif image/png image/jpe image/swf image/jpeg image/bmp
    # Don’t compress images and other #排除不需要压缩的文件
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4.0[678] no-gzip
    BrowserMatch MSIE !no-gzip !gzip-only-text/html
    SetEnvIfNoCase Request_URI .(?:html|htm)$ no-gzip dont-varySetEnvIfNoCase
    #SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:pdf|doc)$ no-gzip dont-vary
    </IfModule>

    2.Expires
    Expires字段声明了一个网页或URL地址不再被浏览器缓存的时间,一旦超过了这个时间,浏览器都应该联系原始服务器。

    #启用expires_module模块
    LoadModule expires_module modules/mod_expires.so
    # 启用有效期控制
    ExpiresActive On
    # GIF有效期为1个月
    ExpiresByType image/gif A2592000
    # HTML文档的有效期是最后修改时刻后的一星期
    ExpiresByType text/html M604800
    #以下的含义类似
    ExpiresByType text/css "now plus 2 months"
    ExpiresByType text/js "now plus 2 days"
    ExpiresByType image/jpeg "access plus 2 months"
    ExpiresByType image/bmp "access plus 2 months"
    ExpiresByType image/x-icon "access plus 2 months"
    ExpiresByType image/png "access plus 2 months"

  • 相关阅读:
    JAVA动态代理
    图解 Tomcat 体系结构
    AdvancedDataGrid的使用
    You have an error in your SQL syntax; check the manual that corresponds...错误解决方案
    更新整站索引时失败,错误原因: [Incorrect integer value: `` for column `uptime` at row 1]
    dedecms转换v9 卡住的解决办法
    IIS 涉及到500和403或者404友好错误的设置!
    PHP Warning: date(): It is not safe to rely on the system's timezone settings
    不能读取记录;在 'MSysObjects' 上没有读取数据权限
    PHP5.3.5如何连接MSSql Server2005
  • 原文地址:https://www.cnblogs.com/liuswi/p/6835794.html
Copyright © 2020-2023  润新知