[英]force browser to re-cache cdn
If a resource is located on my server (say /js/somefile.js
), I sometimes do things like <script src="/js/somefile.js?v=3" type="text/javascript"></script>
and update v
whenever changes are made to ensure a user's client doesn't use the old cached version. 如果资源位于我的服务器上(例如
/js/somefile.js
),我有时会做<script src="/js/somefile.js?v=3" type="text/javascript"></script>
事情<script src="/js/somefile.js?v=3" type="text/javascript"></script>
并v
任何更改时更新v
,以确保用户的客户端不使用旧的缓存版本。
What should be done if using a CDN resource? 如果使用CDN资源该怎么办?
CDN resources should have a version in the URL. CDN资源的URL中应具有版本。 For example Google's CDN URL for JQuery 2.1.4 is https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js .
例如,JQuery 2.1.4的Google CDN URL是https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js 。 If the version of JQuery changes so should the path to the new version.
如果JQuery的版本更改,则新版本的路径也应更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.