利用浏览器缓存 js?ver=
Leverage Browser Caching js?ver=
我的杠杆浏览器缓存遇到了一个奇怪的问题。在我的 .htaccess
中,我使用以下内容:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
这成功缓存了我的网站。但我面临的问题是它丢失了一些 non-external JS 文件:
http://example.com/wp-content/themes/tracks/js/build/production.min.js?ver=4.7.2 (2 days)
http://example.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1 (2 days)
http://example.com/wp-includes/js/jquery/jquery.js?ver=1.12.4 (2 days)
http://exmaple.com/wp-includes/js/wp-embed.min.js?ver=4.7.2 (2 days)
http://example.com/wp-includes/js/wp-emoji-release.min.js?ver=4.7.2 (2 days)
我尝试通过添加以下行来修复它,但结果仍然相同:
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType application/json “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 month”
知道为什么它没有接收到 js?ver=
以及如何解决这个问题吗?如果有帮助:
托管: Hostinger
服务器: Apache 2.4
好的,我设法解决了这个问题。我使用以下四行是正确的:
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType application/json “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 month”
但是,access plus
部分周围的引号出于某种原因是弯引号。因此,这会返回 500
和 503
服务器错误。替换引号后,它已经解决了我的问题,现在也可以正确缓存 js?ver=
个文件。
我最终的杠杆浏览器缓存代码如下所示:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/json "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
我的杠杆浏览器缓存遇到了一个奇怪的问题。在我的 .htaccess
中,我使用以下内容:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##
这成功缓存了我的网站。但我面临的问题是它丢失了一些 non-external JS 文件:
http://example.com/wp-content/themes/tracks/js/build/production.min.js?ver=4.7.2 (2 days)
http://example.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1 (2 days)
http://example.com/wp-includes/js/jquery/jquery.js?ver=1.12.4 (2 days)
http://exmaple.com/wp-includes/js/wp-embed.min.js?ver=4.7.2 (2 days)
http://example.com/wp-includes/js/wp-emoji-release.min.js?ver=4.7.2 (2 days)
我尝试通过添加以下行来修复它,但结果仍然相同:
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType application/json “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 month”
知道为什么它没有接收到 js?ver=
以及如何解决这个问题吗?如果有帮助:
托管: Hostinger
服务器: Apache 2.4
好的,我设法解决了这个问题。我使用以下四行是正确的:
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType application/javascript “access plus 1 month”
ExpiresByType application/json “access plus 1 month”
ExpiresByType application/x-javascript “access plus 1 month”
但是,access plus
部分周围的引号出于某种原因是弯引号。因此,这会返回 500
和 503
服务器错误。替换引号后,它已经解决了我的问题,现在也可以正确缓存 js?ver=
个文件。
我最终的杠杆浏览器缓存代码如下所示:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/json "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##