apache_conf .htaccess更好的Google页面速​​度结果规则 - 这是我添加到任何我希望显着增加的网站的一组默认规则

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf .htaccess更好的Google页面速​​度结果规则 - 这是我添加到任何我希望显着增加的网站的一组默认规则相关的知识,希望对你有一定的参考价值。

# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
 
# Set up caching on media files for 1 year (forever?)
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault A29030400
Header append Cache-Control "public"
</FilesMatch>
 
# Set up caching on media files for 1 week
<FilesMatch "\.(gif|jpg|jpeg|png|swf)$">
ExpiresDefault A604800
Header append Cache-Control "public"
</FilesMatch>
 
# Set up 2 Hour caching on commonly updated files
<FilesMatch "\.(xml|txt|js|css)$">
ExpiresDefault A604800
Header append Cache-Control "proxy-revalidate"
</FilesMatch>
 
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary Accept-Encoding
</FilesMatch>
 
# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
ExpiresActive Off
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
 
AddEncoding gzip .gz
<Files *.css.gz>
  ForceType text/css
</Files>
<Files *.js.gz>
  ForceType text/javascript
</Files>
<FilesMatch .*\.(js|css)>
  RewriteEngine On
  RewriteCond %{HTTP_USER_AGENT} !MSIE
  RewriteCond %{HTTP:Accept-encoding} gzip
  RewriteCond %{REQUEST_FILENAME}.gz -f
  RewriteRule ^(.*)$ $1.gz [L]
</FilesMatch>

以上是关于apache_conf .htaccess更好的Google页面速​​度结果规则 - 这是我添加到任何我希望显着增加的网站的一组默认规则的主要内容,如果未能解决你的问题,请参考以下文章

apache_conf 通过.htaccess(主.htaccess)保护wordpress网站

apache_conf [linux:.htaccess] apache的htaccess说明。 #linux #apache

apache_conf htaccess的

apache_conf [htaccess的]

apache_conf 的.htaccess

apache_conf 的.htaccess