What is the meaning of the curly braces at the end of a js file link?

I've seen code like this and wondering what are those curly braces, is this some kind of archaic passage?

<script type="text/javascript" src="some_script.js?{0}"></script>

      

+3


source to share


3 answers


In the URL, ?

there is a query string after the question mark . This is where you specify the parameters for the server.



In this case, since those parentheses are not encoded (as %7B0%7D

), I suspect you are actually seeing this in the context of the templating engine, but rather {0}

a random number. This is usually used to avoid caching files, since with a random number, you get a new URL every time. I don't know which templating engine you are using ... several use this notation.

+5


source


it looks like a way to avoid browser caching. some people do it like this:



<script type="text/javascript" src="some_script.js?timestamp=1235124321"></script>

      

+2


source


No special meaning, it's just part of the url (since ?

it's part of the query string after ).

Some code (which can be server-side or client-side) might do something with it, but this is website specific.

It can be updated programmatically to act like a cache busting function (changing the number changes the url, so the script will load as a new url, not as a cached version with a potentially stale script in it).

+2


source







All Articles