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

如何采用.htaccess设置网站的压缩与缓存
在网站根目录下的.htaccess文件中添加以下代码


文章由脚本100提供,希望本文所述对大家 学习php有所帮助,也希望大家继续关注脚本100

转载原文地址:http://www.jb100.net/html/content-22-738-1.html

  1. <IfModule mod_expires.c> 

  2. ExpiresActive On 

  3. ExpiresByType image/gif A2592000 

  4. ExpiresByType image/jpeg A2592000 

  5. ExpiresByType image/png A2592000 

  6. ExpiresByType application/x-shockwave-flash A2592000 

  7. ExpiresByType text/css A2592000 

  8. ExpiresByType application/x-javascript A2592000 

  9. ExpiresByType application/javascript A2592000 

  10. ExpiresByType text/javascript A2592000 

  11. ExpiresByType text/html A600 

  12. </IfModule> 

  13.  

  14. <IfModule mod_deflate.c> 

  15. <FilesMatch "\.(js|css|html|htm)$"> 

  16. SetOutputFilter DEFLATE 

  17. </FilesMatch> 

  18. </IfModule> 

  19.  

  20. <ifModule mod_gzip.c> 

  21.   mod_gzip_on Yes 

  22.   mod_gzip_dechunk Yes 

  23.   mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ 

  24.   mod_gzip_item_include handler ^cgi-script$ 

  25.   mod_gzip_item_include mime ^text/.* 

  26.   mod_gzip_item_include mime ^application/x-javascript.* 

  27.   mod_gzip_item_exclude mime ^image/.* 

  28.   mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* 

  29. </ifModule> 

  30.  

  31. <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css)$"> 

  32. Header unset Last-Modified 

  33. </FilesMatch> 

  34.  

  35. FileETag none 


现在使用Firefox的YSlow插件,以Small Site or Blog标准测试的分数为99分,以YSlow2(V2)标准测试的分数为94分,被扣掉的几分主要是因为没有使用CDN。所以现在速度已经被优化到了极

致。

赶快把它放到你的网站或blog根目录下的.htaccess文件里吧。

文章由脚本100提供,希望本文所述对大家 学习php有所帮助,也希望大家继续关注脚本100

转载原文地址:http://www.jb100.net/html/content-22-738-1.html


转载于:https://my.oschina.net/u/2285640/blog/353047

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值