Jee*_*Jsb 13 javascript caching google-chrome
当我部署版本时,我会将数字作为查询字符串添加到JavaScript和CSS文件中,如下所示?
'app/source/scripts/project.js?burst=32472938'
Run Code Online (Sandbox Code Playgroud)
我正在使用上面的内容在浏览器中突发缓存.
但在Firefox中,我得到了我修改过的最新脚本.但在Chrome中,我没有收到我修改过的最新脚本.而不是那样,我得到旧的.
但是在开发者控制台中,我看到了最新修改的突发数量.
根据Google文档,无效和重新加载文件的最佳方法是在文件名中添加版本号,而不是作为查询参数:
'app/source/scripts/project.32472938.js'
以下是文档的链接:https:
//developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#invalidating_and_updating_cached_responses
另一种方法是使用ETag(验证令牌):https:
//developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#validating_cached_responses_with_etags
以下是如何使用Nginx设置ETag:http:
//nginx.org/en/docs/http/ngx_http_core_module.html#etag
最后,有关使用Nginx和ETag进行浏览器缓存的教程:https:
//www.digitalocean.com/community/tutorials/how-to-implement-browser-caching-with-nginx-s-header-module-on-centos -7#步骤-2-%14检查的所述默认行为
归档时间: |
|
查看次数: |
1057 次 |
最近记录: |