is there a cdn for the lastest jquery with a cache time?
jquery gives you the possibility to do a:
<script src="http://code.jquery.com/jquery-latest.js"></script>
the problem is that file hasn't any expiration date, so the client will always require it.
The other开发者_JS百科 option is http://ajax.googleapis.com/ajax/libs/jquery/x.x.x/jquery.min.js
that has a 1year expire
So, someone know a cdn offering a jquery-latest.js with some cache time?
No.
The reason that specifying a far-future expires header improves performance is that the browser can immediately use a local copy of that file if it's within the expires timeframe. The browser won't make an HTTP request at all in that case, not even to check for a 304 "Not Modified" response.
That means a "latest version" reference cannot be served with a performance-optimized expires header. If it were, there would be no guarantee at all which version of the file any given browser might be using for the reference.
In production, you should always use the fully qualified x.y.z version number, and not one of the "get latest" references. Google's CDN serves jQuery with a +1 year expires header when you reference it that way, which combined with the cross-site caching potential of public CDNs, means that many of your users may never even need to make an HTTP request for jQuery on your site at all.
精彩评论