为什么drupal将版本号添加到js路径?

为什么drupal将版本号添加到js路径?,drupal,Drupal,为什么drupal会将版本号(比如?v=XXX)添加到.js库中? 例如: <script type="text/javascript" src="http://localhost/misc/jquery.js?v=1.4.4"></script> 就像他们在这里说的:以前跟踪jquery版本并不简单 由于您可以在drupal页面中使用jquery功能,因此您必须知道您使用的是哪个版本,才能确切知道存在哪些功能。关于虚拟文本(关于Peter指向链接的版本),让我们看看d

为什么drupal会将版本号(比如?v=XXX)添加到.js库中? 例如:

<script type="text/javascript" src="http://localhost/misc/jquery.js?v=1.4.4"></script>
就像他们在这里说的:以前跟踪jquery版本并不简单

由于您可以在drupal页面中使用jquery功能,因此您必须知道您使用的是哪个版本,才能确切知道存在哪些功能。

关于虚拟文本(关于Peter指向链接的版本),让我们看看drupal/includes文件夹中common.inc文件的注释:

function drupal_get_js($scope = 'header', $javascript = NULL) {
  ..
  // A dummy query-string is added to filenames, to gain control over
  // browser-caching. The string changes on every update or full cache
  // flush, forcing browsers to load a new copy of the files, as the
  // URL changed. Files that should not be cached (see drupal_add_js())
  // get time() as query-string instead, to enforce reload on every
  // page request.
  $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
  ..
}

function drupal_get_css($css = NULL) {
  ..
  // A dummy query-string is added to filenames, to gain control over
  // browser-caching. The string changes on every update or full cache
  // flush, forcing browsers to load a new copy of the files, as the
  // URL changed.
  $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
common.inc
  ..
}

我认为这可以防止浏览器在本地缓存文件,并且在开发过程中非常有用。一旦准备好启动,就可以在配置/性能管理部分打开CSS/JS聚合。
function drupal_get_js($scope = 'header', $javascript = NULL) {
  ..
  // A dummy query-string is added to filenames, to gain control over
  // browser-caching. The string changes on every update or full cache
  // flush, forcing browsers to load a new copy of the files, as the
  // URL changed. Files that should not be cached (see drupal_add_js())
  // get time() as query-string instead, to enforce reload on every
  // page request.
  $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
  ..
}

function drupal_get_css($css = NULL) {
  ..
  // A dummy query-string is added to filenames, to gain control over
  // browser-caching. The string changes on every update or full cache
  // flush, forcing browsers to load a new copy of the files, as the
  // URL changed.
  $query_string = '?'. substr(variable_get('css_js_query_string', '0'), 0, 1);
common.inc
  ..
}