views:

300

answers:

3

I have a script which at one point returns an image thumbnail using jquery built in java request.

Every time the php function get called, this thumbnail gets updated, but keeps the exact same filename. Problem is that the browser caches the thumbnail and it looks like it never gets updated.

Are here any techniques to avoid this?

+2  A: 

You may add time() function at the end of the file name. Ex

<img src="myImage.jpg?<?php echo time();?>" />
Ahmet Kakıcı
Thank you very much! Every time I forget about time(). [no pun intended]
0plus1
A: 

You can set the cache option to false. See the documentation.

kgiannakakis
A: 

In your AJAX call:

'image.php?'+(new Date().getTime())

jQuery has similar functionality built-in with its cache-option.

brownstone