views:

9

answers:

1

I saw this in a HTML template for a web app:

<img alt="mybutton" src="/img/button.png?123456789" />

What I didn't understand was why the ?123456789 would be passed to the image file? (in the actual app, the number that was actually passed seemed to be customized to the user's session or unique id perhaps)

+2  A: 

It forces the browser to skip its cache, and retrieve a fresh copy from the server.

Lekensteyn
It forces the browser not to use its own cache?
LowFatTwinkie
Yes. That's useful when a website gets a new design for example.
Lekensteyn
But if they change the number at each session, for example, the browser has to load new images every time, which seems like a loss of efficiency for the user and puts more bandwidth strain on the servers.
LowFatTwinkie
That's true. If an image has to be regenerated every time, it should be done in this way. But if it doesn't have to be regenerated every time, then it's an error from the web developer.
Lekensteyn