-3

Nowadays In most of the sites i am seeing url like this

http://example.com/style.css?v=024741259dd2

Where style.css is appended with some text. What is this appended text is it some version number or date and time? If yes how is it generated? What is the significance of this?

AlBlue
  • 23,254
  • 14
  • 71
  • 91
karthick
  • 11,998
  • 6
  • 56
  • 88

1 Answers1

3

it is probably a "random" number (e.g. a file checksum, or the SHA of a commit under a versioning system, or the resource timestamp in MD5 format, or...) generated automatically on server-side as a cachebusting technique. The purpose is to invalidate the browser cache for that resource if you've already loaded it and a change was made.

As example, I always use that technique while I am developing a website with Jekyll and Jekyll-assets, so I can be sure to always see my recent changes without reloading my javascript and stylesheets file from the cache.

Fabrizio Calderan
  • 120,726
  • 26
  • 164
  • 177
  • Why do people want to do that. JS and CSS are meant to be cached isn't it? – karthick Jun 26 '13 at 08:42
  • 1
    Yes, but once you update your styles and javascript files you want to be sure that users use the latest versions. – Alessandro Vendruscolo Jun 26 '13 at 08:43
  • yes, but the idea is to change that parameter only when a change is made and not on every page refresh. – Fabrizio Calderan Jun 26 '13 at 08:44
  • Ordinarily it's not a random number, but e.g. the last-modified timestamp or the file's md5 - so that the url only changes when the file's contents do. – AD7six Jun 26 '13 at 08:46
  • it can also be a substring of the file checksum or it can be the sha of the commit if that file is under a versioning system. Or it can be generated by a `rand()`. It depends on the system who generated it – Fabrizio Calderan Jun 26 '13 at 08:48