开发者

What is the ? in html links tags?

If you have a li开发者_运维问答nk or script tag, say to a css or js document, and you have something like ?1 in the url, what is that? Example:

<script src="home.js?1" type="text/javascript"></script>

Just a basic question...


This is for caching purposes. For example, the next time that script gets updated the developer can add a ?2 at the end and the browser will fetch the new version not the cached.


It denotes the beginning of the Query String, used to pass values around, or commonly just to create a randomized portion of the URL to avoid cached results.

In your example, the user is likely tacking on a new value to constantly create a unique URL that ultimately goes to the same place, and requests the same thing.


The part after the question mark is called the query string.

The query string is ignored when the server maps the request to a file on disk, but it can be used by server-side scripts.

In this case, the query string is being used to avoid caching.
When the script is changed, the query string can be changed to ?2 and it will not use the previous version from the cache.


It just keeps it from caching. Normally the browser caches those files, so adding a ? plus a random number will make the browser see it as a different url, thus reloading the file. Its not really necessary since most browsers will reload cached files with Ctrl+R.


What follows the ? is the query string. It is used to pass parameters to the src file and sometimes to prevent caching by adding a random number to the file string to force the browser to fetch from the server.


The '?' separates the resource identifier from the query parameters of the URL. I'm not sure if I'm naming them correctly. Often a CMS will add ?1 to the URL for a CSS or other page to avoid browser cacheing for the elements. Each time you edit the CSS, the number will get bumped to the next value so the browser is sure to reload the CSS or script or whatever.


? separates the URL from the parameters. Parameters would follow the ?. After the ? you should use & separate multiple parmaeters. e.g. www.google.com?q=URL&language=en

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜