What is it? in html link tags?

If you have a link or script tag, say css or js in the document and do you have something like? 1 in the url, what is it? Example:

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

Just the main question ...

+4
source share
7 answers

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

+11
source

It marks the beginning of the query string used to pass values ​​around, or usually just to create a randomized portion of the URL to avoid cached results.

In your example, the user is most likely tied to a new value in order to constantly create a unique URL that ultimately goes to the same place and asks for the same thing.

+7
source

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

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

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

+1
source

It just keeps it from caching. Usually the browser caches these files, so adding? plus a random number will make the browser see it as a different URL, thus reloading the file. This is not necessary, as most browsers reload cached files with Ctrl + R.

+1
source

What follows? This is a 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 line to force the browser to retrieve data from the server.

+1
source

"?" separates the resource identifier from the request parameters of the URL. I'm not sure if I named them correctly. Often does CMS add? 1 to the URL for CSS or another page to avoid browser caching for elements. Every time you edit CSS, the number will be filled to the next value, so the browser will definitely reload the CSS or script or something else.

+1
source

? Separates URLs from parameters. Will the parameters follow ?. After? You must use and share multiple parameters. e.g. www.google.com?q=URL&language=en

0
source

Source: https://habr.com/ru/post/1301503/


All Articles