• 如何巧用.htaccess设置网站的压缩与缓存


        <IfModule mod_expires.c>
        ExpiresActive On
    • ExpiresDefault A86400
    ExpiresByType image/gif A2592000
        ExpiresByType image/jpeg A2592000
        ExpiresByType image/png A2592000
        ExpiresByType application/x-shockwave-flash A2592000
        ExpiresByType text/css A2592000
        ExpiresByType application/x-javascript A2592000
        ExpiresByType application/javascript A2592000
        ExpiresByType text/javascript A2592000
        ExpiresByType text/html A600
        </IfModule>
    
        <IfModule mod_deflate.c>
        <FilesMatch ".(js|css|html|htm)$">
        SetOutputFilter DEFLATE
        </FilesMatch>
        </IfModule>
    
        <ifModule mod_gzip.c>
          mod_gzip_on Yes
          mod_gzip_dechunk Yes
          mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
          mod_gzip_item_include handler ^cgi-script$
          mod_gzip_item_include mime ^text/.*
          mod_gzip_item_include mime ^application/x-javascript.*
          mod_gzip_item_exclude mime ^image/.*
          mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
        </ifModule>
    
        <FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css)$">
        Header unset Last-Modified
        </FilesMatch>
    
        FileETag none

    例二:

    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault A0
    # 1 年
    <FilesMatch “.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$”>
    ExpiresDefault A9030400
    </FilesMatch>
    # 1 星期
    <FilesMatch “.(jpg|jpeg|png|gif|swf)$”>
    ExpiresDefault A604800
    </FilesMatch>
    # 3 小时
    <FilesMatch “.(txt|xml|js|css)$”>
    ExpiresDefault A10800″
    </FilesMatch>
    </IfModule>

  • 相关阅读:
    vim编辑器
    linux常用的命令解释
    克隆虚拟机及本地仓库的搭建
    创建windows系统下的虚拟机
    创建linux系统下的虚拟机
    drf频率组件
    django中过滤 搜索 排序
    drf分页
    js回顾
    数据类型
  • 原文地址:https://www.cnblogs.com/ahwu/p/4139147.html
Copyright © 2020-2023  润新知