由于google的pagespeed工具的建议,我正在尝试优化我的网站。它说我要为这些文件制作“利用浏览器缓存”; `
http://cdn.api.twitter.com/.../count.json?... (3.6 minutes)
http://cdn.api.twitter.com/.../count.json?... (3.6 minutes)
http://cdn.api.twitter.com/.../count.json?... (5.2 minutes)
http://cdn.api.twitter.com/.../count.json?... (13.2 minutes)
http://cdn.api.twitter.com/.../count.json?... (14 minutes)
http://cdn.api.twitter.com/.../count.json?... (14.5 minutes)
http://cdn.api.twitter.com/.../count.json?... (14.9 minutes)
http://cdn.api.twitter.com/.../count.json?... (15 minutes)
http://cdn.api.twitter.com/.../count.json?... (15 minutes)
http://static.ak.fbcdn.net/connect.php/css/share-button-css (16.8 minutes)
http://static.ak.fbcdn.net/connect.php/js/FB.Share (18.3 minutes)
http://connect.facebook.net/tr_TR/all.js (19 minutes)
http://platform.twitter.com/widgets.js (30 minutes)
https://apis.google.com/js/plusone.js (60 minutes)
` 我知道如何在.htaccess文件中使用mod_expires.c缓存我自己的js,css文件,但是不知道如何缓存这些文件?
这是我的.htaccess文件 `
# BEGIN Compress text files
<ifModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</ifModule>
# END Compress text files
# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 604800 seconds"
ExpiresByType application/javascript "access plus 604800 seconds"
ExpiresByType application/x-javascript "access plus 604800 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifModule>
# END Expire headers
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
# END Cache-Control Headers
# BEGIN Turn ETags Off
FileETag None
# END Turn ETags Off
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://domain.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.domain.com$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
`
答案 0 :(得分:0)
除非您制作副本并将其托管在您控制的域中,否则无法对其进行缓存。