head 标签中 src/href 属性末尾的奇怪字符 [英] Weird characters at the end of src/href attributes in head tag
问题描述
快速问题:为什么drupal在link
和script<的
src
或href
属性的末尾添加字符/code> 标签在页面的头部?我有这个:
Quick question : Why is drupal adding characters at the end of the src
or href
attributes in the link
and script
tags in the head of the page ? I have this :
<link type="text/css" rel="stylesheet" media="all" href="/ste_thecle/modules/views/css/views.css?n" />
并且对于加载的每个样式表和脚本都是相同的.我不明白为什么要这样做,我想这可能是我的主题在 IE 中全部搞砸的原因...
And it is the same for every stylesheet and script loaded. I can't figure out why it's doing that, and I think maybe it's the reason why my theme is all messed up in IE...
谢谢.
推荐答案
每次浏览器加载外部 JavaScript 文件时,浏览器都会将该文件放入其缓存中.这样,当您第二次重新加载页面并尝试加载相同的外部文件时,浏览器将从缓存中使用它.
Each time the browser loads an external JavaScript file, the browser put the file in its cache. This way, the second time you will reload the page and try to load the same external file, the browser will use it from the cache.
如果您对 JavaScript 文件进行更改并尝试重新加载页面,则更改将不会生效,因为浏览器将使用缓存文件.
If you make a change in the JavaScript file and try to reload your page, the changes will not take effect because the browser will use the cache file.
为了防止这种行为,Drupal 将在 JavaScript 文件的 URL 末尾添加一个随机值.这样浏览器就会将该文件视为新文件,而不会使用浏览器缓存中的文件.
To prevent this behavior, Drupal will add a random value at the end of the URL of the JavaScript file. This way the browser will see the file as a new file and will not use the file in the browser cache.
一个好的做法是在生产阶段删除此功能,以便页面加载速度更快.
A good practice is to remove this functionality in production stage so the page will load faster.
这篇关于head 标签中 src/href 属性末尾的奇怪字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!