Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the ? in html links tags?

If you have a link 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...

like image 276
Matthew Westrik Avatar asked Nov 30 '22 06:11

Matthew Westrik


2 Answers

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.

like image 24
Sampson Avatar answered Dec 01 '22 18:12

Sampson


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.

like image 99
Darko Z Avatar answered Dec 01 '22 20:12

Darko Z