2011-09-28 40 views
1

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

<script type="text/javascript" src="http://localhost/misc/jquery.js?v=1.4.4"></script> 

拿什么在路径的末尾奇怪的文字.css文件(符号后 '?'):

@import url("http://localhost/modules/system/system.menus.css?lrrru5"); 
+1

我想这可以防止在本地缓存文件浏览器,是非常有用的在开发期间。一旦准备好启动,您可以在配置/性能管理部分打开CSS/JS聚合。 – Finbarr

回答

2

关于虚拟文本(有关版本彼得点链接),让我们来看看它在Drupal 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 
    .. 
} 
+1

+1:这个问题可能的最佳来源。 – Peter

1

就像他们在这里说:http://drupal.org/node/82831:这是跟踪jquery版本之前并不简单。

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

相关问题