开发者

Weird characters at the end of src/href attributes in head tag

开发者 https://www.devze.com 2023-01-14 09:37 出处:网络
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 :

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" />

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...

Thanks.


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.

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.

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.


These things are added in order to force the cache control. It has nothing to do with the messed up theme in IE.


Because a different query string (?n) is added every time, your browser 'thinks' that the resource is different, so it reloads the file instead of retrieving it from cache. By doing this, Drupal makes sure that you're not looking at stale files that have been changed since they were cached.

0

精彩评论

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