我已粘贴此代码:
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest "access plus 0 seconds"
# Your document html
ExpiresByType text/html "access plus 0 seconds"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
# Feed
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/atom+xml "access plus 1 hour"
# Favicon (cannot be renamed)
ExpiresByType image/x-icon "access plus 1 week"
ExpiresByType image/icon "access plus 1 week"
ExpiresByType image/ico "access plus 1 week"
# Media: images, video, audio
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
# HTC files (css3pie)
ExpiresByType text/x-component "access plus 1 month"
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
# Compress compressible fonts
AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-opentype image/svg+xml
# Add a far future Expires header for fonts
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
# CSS and JavaScript
ExpiresByType text/css "access plus 1 year"
ExpiresByType text/javascript "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
<IfModule mod_headers.c>
Header append Cache-Control "public"
</IfModule>
</IfModule>
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<files *.html>
SetOutputFilter DEFLATE
</files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
当我运行GoogleInsights anlayze工具时,我发现de compression(代码)已被识别,但浏览器兑现代码未被识别!我不明白为什么,因为这是建议的默认代码(对于Apache服务器)?我的网站是http://computertechnet.nl。 我怎么能解决这个问题? 谢谢 约翰内斯
答案 0 :(得分:0)
这不是问题。当我通过Google Page Insights运行您的网站时,它会标记&#34;利用浏览器缓存&#34;根据&#34;考虑修复&#34;部分,但是当我扩展它时,我看到以下内容:
利用浏览器缓存
在静态资源的HTTP标头中设置过期日期或最长期限,指示浏览器加载以前下载的内容 来自本地磁盘而非网络的资源。
利用浏览器缓存以获取以下可缓存资源: http://maps.googleapis.com/ ... PS / API / JS V = 3.exp&安培;传感器=假安培;版本4.3.1 = (30分钟)
换句话说,您网站上托管的所有内容都已正确缓存,但您从其他网站吸引了一些Javascript(具有讽刺意味的是,足够!)只会缓存30分钟而Google Page Insights认为不是够久了。
因此,您网站上的其他所有内容都会被缓存。如果它不是标记在&#34;应该修复&#34;部分。所以不用担心这个。
是的,令人讨厌的是,Google Page Insights没有认识到1)这是一个外部资源,2)它是Google的外部资源,所以他们不应该标记它。
我怀疑你过分关注标题数字(60/100),但这主要是因为你的服务器太慢(3秒响应),你有一个,坦率地说,荒谬的22种不同的css样式表(加载另外3秒加载时间),你有一个1.5Mb的图像。
见这里: http://www.webpagetest.org/result/151126_DX_17W7/
网站应该在2秒内加载 - 理想情况下在100毫秒以内,用户完全不会注意到,但这几乎是不可能实现的。您的网站至少需要9秒钟。