开发者

How do I interpret. /glow.min.js?v=5

Please tell me what does /glow.min.js?v=5 means How this is used? i.e How 开发者_Go百科the versioning is done here as file is one.


It means to grab glow.min.js from the root of the server, with a simplistic attempt to control caching via a query string.

The query string does nothing unless the server is set up to handle it, which typically it isn't and so the server just throws away the query string. This is sometimes done to control caching, the theory being that if the resource is delivered with HTTP 1.1 (because HTTP 1.0 resources with query strings aren't cached), the browser is allowed to reuse the resource if the query string matches, but if you change it to v=6, then the browser is expected to re-fetch the resource (presumably you've changed the underlying file).

There are better ways to manage caching than query strings. This article gives a good account of what that code is doing and alternatives for doing it other ways. Some select points made in the article:

  • Make caches store images and pages that don’t change often by using a Cache-Control: max-age header with a large value.
  • Make caches recognise regularly updated pages by specifying an appropriate max-age or expiration time.
  • If a resource (especially a downloadable file) changes, change its name. That way, you can make it expire far in the future, and still guarantee that the correct version is served; the page that links to it is the only one that will need a short expiry time.

But read the article for much more insight.

That last point, "if a resource changes, change its name" should be particularly easy in your case, since I assume you're referencing the BBC's Glow library which will already have a version you could use in the main URL (rather than in the query string).

I'll just add my own point:

  • Take advantage of CDNs when you can. I'm a bit surprised to see that that library isn't on the Google Ajax Libraries list, but it doesn't seem to be. You might check in the Glow discussion group to see if the library is hosted on a CDN somewhere (Google's is not the only one, after all).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜