0

I found that some website use parameters on image src like ?v=1390510765392

what is it used for ?

<img src="image.jpg?v=1390510765392" />

Found on that Angularjs example

Merlin
  • 4,907
  • 2
  • 33
  • 51

5 Answers5

2

I can think of two possible uses...

  1. If the parameter randomly changes every time the page is loaded, then it's a common means of preventing the browser from caching the image. This would force the browser to always request a new one (because the URL is different) so that the user always has the latest version.

  2. If image.jpg isn't actually an image but rather a code-driven server-side resource which responds with an image, then URL parameters would be a way to pass an identifier to that resource to identify which specific image data to download. (Such as if the images, or at least references to them, are stored in a database.)

The first one is very likely what's happening here, though the second is certainly possible.

David
  • 208,112
  • 36
  • 198
  • 279
  • I use technique #1 with CSS background images which are generally cached more aggressively than HTML images (depending on the browser). – Aaron Jan 23 '14 at 21:36
2

The src attribute of the element is simply passing the GET variable v to the server at the image.jpg endpoint with a value of 1390510765392. Without examining the server-side code, it is unclear why the developer is doing this. A few possibilities come to mind:

  • image.jpg could actually be a script (or interpreted by one) despite the .jpg extension, in which case it is possible that 1390510765392 is a resource token used to retrieve a specific image.
  • A frequent use of such a parameter is to simply change the src attribute without actually changing what it points at, thus invalidating any client-side (or intermediary) cache of the image and forcing it to reload, in which case the server itself likely ignores v.
bosco
  • 232
  • 4
  • 13
1

It allows for the name of the image to remain the same but by appending the query string it prevents browsers from using a cached version of the image. The query string essentially makes the URL "new" so the browser goes and gets what it believes to be a new resource.

John Conde
  • 217,595
  • 99
  • 455
  • 496
1

It's used to avoid image to be served from browser cache (because the URL is different if date changes and it makes no effect on images)

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
0

Another possabilty is to avoid flushing CDN resources when the image changes preventing the user from seeing an old version if the image.

Lior Asta
  • 121
  • 3