设置网站的缓存和压缩
| |
2012/10/22 建站
在网站根目录下的.htaccess文件中添加以下代码

  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

10K
本文来源: 噜噜网 | 目前已有 25634 人围观此文,标签: ,

浮上来留个足迹吧,看帖不回会被鄙视de哦: