Home > php教程 > php手册 > body text

采用.htaccess设置网站的压缩与缓存

WBOY
Release: 2016-06-21 08:56:35
Original
1004 people have browsed it

原文标题:设置blog的缓存和压缩

在网站根目录下的.htaccess文件中添加以下代码


ExpiresActive On
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



SetOutputFilter DEFLATE


  mod_gzip_on Yes
  mod_gzip_dechunk Yes
  mod_gzip_item_include file \.(html?txtcssjsphppl)$
  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.*


Header unset Last-Modified

FileETag none

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

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



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template