代码之家  ›  专栏  ›  技术社区  ›  easel

为什么Drupal附加?1到我的CSS文件链接

  •  2
  • easel  · 技术社区  · 16 年前

    我的设计师注意到在Drupal站点的源代码中,所有的.css文件都被附加了一个?他担心会破坏一切。为什么要这样做?

    <link type="text/css" rel="stylesheet" media="all" href="/modules/modules/node/node.css?l" />
    <link type="text/css" rel="stylesheet" media="all" href="/modules/modules/system/defaults.css?l" />
    <link type="text/css" rel="stylesheet" media="all" href="/modules/modules/system/system.css?l" />
    <link type="text/css" rel="stylesheet" media="all" href="/modules/modules/system/system-menus.css?l" />
    <link type="text/css" rel="stylesheet" media="all" href="/modules/modules/user/user.css?l" />
    
    2 回复  |  直到 16 年前
        1
  •  10
  •   easel    16 年前

    我在Drupal的源代码中找到了:

    // 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);
    

    我想这就是答案。我想,既然Drupal的人这样做了,浏览器在CSS链接标签中使用查询字符串是很酷的,尽管我的设计师对此很偏执。

    希望这能帮助某个人在一天的谷歌=p

        2
  •  4
  •   Peter Å tibraný    16 年前

    以下博客文章也解释了这种做法: mod_expires and Cache Killers