请输入
菜单

apache 开启JS和图片缓存

下载

修改 APACHE 配置文件 \ldcrm\apache\conf\httpd.conf

LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so

确认 APACHE 加载了以上两个模块(前面的注释符号 #  去掉),然后再在配置文件最后添加

<IfModule mod_expires.c>
        # 启用有效期控制
        ExpiresActive On
        # image
        ExpiresByType image/jpg "access plus 1 month"
        ExpiresByType image/jpeg "access plus 1 month"
        ExpiresByType image/gif "access plus 1 month"
        ExpiresByType image/png "access plus 1 month"
        ExpiresByType image/x-icon "access plus 1 month"
        # css/js
        ExpiresByType text/css "access plus 4 weeks"
        ExpiresByType text/javascript "access plus 4 weeks"
        # html
        ExpiresByType text/html "access plus 2 days"
</IfModule>

<IfModule mod_headers.c>
        # 配置mod_headers模块
        <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|woff|js|css|swf)$">
                Header set Cache-Control "max-age=604800"
                FileETag MTime Size
        </FilesMatch>
</IfModule>



重启apache 服务

apache_开启JS和图片缓存.txt

最近修改: 2025-01-15