我在.htaccess中使用以下代码进行浏览器缓存:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
##js-Dateien ins browser-caching einbeziehen
<filesMatch "\\.(js|js.gz)$">
Header set Cache-Control "max-age=604800, private"
</filesMatch>
##Ende js-Dateien ins browser-caching einbeziehen
# Deflate Compression by FileType
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-shockwave-flash
</IfModule>
# turns cache on for 1 month
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
</IfModule>
但是当我运行Pagespeed insight时,有几个.js文件没有包含在浏览器缓存中,例如:
http://www.hwi-sicherheit.de/…awesome/fontawesome-webfont.woff?v=3.2.1 (2 Tage)
http://www.hwi-sicherheit.de/…jquery.form.min.js?ver=3.51.0-2014.06.20 (2,5 Tage)
http://www.hwi-sicherheit.de/…-form-7/includes/js/scripts.js?ver=4.3.1 (2,5 Tage)
http://www.hwi-sicherheit.de/…-wordpress/js/mappress.min.js?ver=2.43.4 (2,5 Tage)
http://www.hwi-sicherheit.de/…-shortcodes/includes/js/rsvp.js?ver=1.82 (2,5 Tage)
http://www.hwi-sicherheit.de/…s/jquery/jquery-migrate.min.js?ver=1.2.1 (2,5 Tage)
http://www.hwi-sicherheit.de/…-includes/js/jquery/jquery.js?ver=1.11.3 (2,5 Tage)
http://www.hwi-sicherheit.de/…s/jquery/jquery.masonry.min.js?ver=3.1.2 (2,5 Tage)
http://www.hwi-sicherheit.de/…/wp-includes/js/masonry.min.js?ver=3.1.2 (2,5 Tage)
http://www.hwi-sicherheit.de/…s/wp-includes/js/wp-embed.min.js?ver=4.4 (2,5 Tage)
为什么不包含这些文件?
答案 0 :(得分:0)
这是因为它无法识别扩展名。
而不是阅读
http://www.hwi-sicherheit.de/…jquery.form.min.js
它读到了这个:
http://www.hwi-sicherheit.de/…s/jquery/jquery-migrate.min.js?ver=1.2.1
删除查询字符串并对参数进行编码
我认为你应该检查一下: https://wordpress.org/plugins/remove-query-strings-from-static-resources/